I have this mssql query
SELECT TOP 50 [id], [title], [url], [icon], linkstats.visits
FROM [websites] LEFT OUTER JOIN [linkstats] ON websites.id=linkstats.lid AND linkstats.code=@country
WHERE (([country] = @country OR [country]= 'all') AND
([hot] = @hot))
ORDER BY linkstats.visits DESC
I want to order by nulls to the end and if all are nulls then order by ID
How to do that?!
use
CASE