Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

ORDER BY com Declaração de Caso DESC

SELECT columns FROM tables 
WHERE condition 
ORDER BY      
   case when Table1.Col1 IS NULL then 0 else 1 end ASC      
   ,case when Table1.Col1 IS NULL then Table2.Col2 else Table1.Col1 end DESC