【发布时间】:2018-09-21 21:35:51
【问题描述】:
我正在尝试按字母顺序对表格进行排序,升序,最后使用空值,但遇到了问题。
下面的代码产生以下错误:
如果指定了 SELECT DISTINCT,则 ORDER BY 项目必须出现在选择列表中。
select distinct
'item' = othertab..item,
'stockedFor' = tab..stocked_for
+ ', ' + tab..stockedFor2
+ ', '+ tab..stockedFor3
from tab
order by case when stockedFor is null then 1 else 0 end, stockedFor
如何按字母顺序返回stockedFor,最后返回空值?
【问题讨论】: