Reputation: 47945
This is my SQL query :
SELECT TOP (200) IDA
FROM Categories
WHERE (IDA = 72)
ORDER BY Order
but it puts the records with Order NULL
before the records with Order as int
. Is there a strategy to change this order? Putting the records with NULL
at the bottom of the result list.
Upvotes: 0
Views: 944
Reputation: 12280
Works for any type:
select top(200) IDA from Categories
order by case when [order] is null then 1 else 0 end, [order]
Upvotes: 2
Reputation: 79939
Yes:
SELECT TOP (200) IDA
FROM Categories
WHERE IDA = 72
ORDER BY
CASE
WHEN [ORDER] IS NULL
THEN 0
ELSE 1
END DESC, [Order]
Upvotes: 2