Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 order by clause with NULL

Author  Topic 

SQLboom
Yak Posting Veteran

63 Posts

Posted - 2003-11-20 : 05:54:17
Hi,
faced with a look simple tedious problem here .. .
the results of same select query w.r.t NULL values in Oracle and SQL Server are as below
Oracle returns:
'a'
'b'
NULL
NULL

whereas in SQL Server it returns
NULL
NULL
'a'
'b'
i.e., there's a differnce in the treatment of NULL values.
I have found that this is because SQL Server assigns least priority to NULL Values and Oracle assigns it the highest. So with an "Order by Acsending clause", SQL Server places NULL values above all the rest and Oracle places them at the end of all the Values.
I am working with SQL Server . .. Can anyone suggest a workaround in SQL Server to get the same output as Oracle ...
Thanks..

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-11-20 : 06:00:42
Hi

You can use isNull to replace NULLs with something else. You could do something like :

ORDER BY isNull(blah, 'zzzzzzzzzzzz')

Look in books online for syntax.


Damian
Go to Top of Page
   

- Advertisement -