我想定制一个订单:IN、OUT、FINISHED。
如果我离开 case 语句,我将进入 FINISHED、IN、OUT。我找到了这个解决方案,但它对我不起作用 - 我遇到了错误。
select distinct 'IN' as STATUS,
(select count(*) ...)
from table
UNION ALL
select distinct 'OUT',
(select count(*) ...)
from table
UNION ALL
select distinct 'FINISHED',
(select count(*) ...)
from table
order by
case STATUS
when 'IN' then 1
when 'OUT' then 2
when 'FINISHED' then 3
end