Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

Why column with null value come before column with values when you order by a timestamp column in oracle 9i

I've got a strange behaviour with an Oracle 9i database. If i make a query like this:

 select * from table order by dp_dt_timestamp DESC;

where dp_dt_timestamp is a timestamp column, rows which have null values in the column dp_dt_timestamp come before those that have a value.

How can i put the null values as the last values and still have the timestamps ordered Descending?

Upvotes: 1

Views: 135

Answers (1)

CyberDude
CyberDude

Reputation: 8959

order by dp_dt_timestamp DESC NULLS LAST

By default NULLs come last when sorting ASC and first when sorting DESC.

Upvotes: 4

Related Questions