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 2005 Forums
 Transact-SQL (2005)
 getting null values to show last

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2009-12-17 : 04:24:33
i'd like to get null values to show last

i tried

select c.country,NullOrderingReversal = case c.country when null then 'Z' else 'A' end
from participants p left join placements pl on p.participantid=pl.participantid and pl.PlacementId in (select top 1 x.PlacementId from Placements x where x.ParticipantId = pl.ParticipantId order by [assumedposition?]) left join country c on c.id=pl.workcountryid group by c.country order by NullOrderingReversal,c.country


but it's still showing the null values first and the value for hte null field of nullorderingreversal is still A


what am i doing wrong?

creieru
Starting Member

12 Posts

Posted - 2009-12-17 : 05:01:46
try this

select c.country,NullOrderingReversal = case when c.country is null then 'Z' else 'A' end
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2009-12-17 : 05:40:29
thanks
Go to Top of Page
   

- Advertisement -