table order by date DESC时,空值是放在最后的。请问如何实现?
A: Select * from
table order by case when date is null then getdate() else date end DESC
Q: 我要求不能显示相同记录而加入DISTINCT:
Select DISTINCT * from
table order by case when date is null then getdate() else date end DESC
但是出错:如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。
如何解决呢?
A: Select * From
(Select DISTINCT * from tableName) AS TABLE order by case when TABLE.date is null then getdate() else TABLE.date end DESC
869




被折叠的 条评论
为什么被折叠?



