case when 查询
select
scrap_detl_id,scrap_ou_qty,scrap_su_qty,scrap_bu_qty,
(
CASE
WHEN scrap_ou_qty NOTNULL and to_number(scrap_ou_qty || '','9999999') > 0
THEN order_unit_name
WHEN scrap_su_qty NOTNULL and to_number(scrap_su_qty || '','9999999') > 0
then unit_name
ELSE bom_unit_name
END) AS scrap_unit_name,
(
CASE
WHEN scrap_ou_qty NOTNULL and to_number(scrap_ou_qty || '','9999999') > 0
THEN scrap_ou_qty
WHEN scrap_su_qty NOTNULL and to_number(scrap_su_qty || '','9999999') > 0
then scrap_su_qty
ELSE scrap_bu_qty
END) AS scrap_qty
from tb_scrap_detl
order by case when then 写法
select user_name,user_id,role from tb_user
where company_id = 'JH'
and parent_id = 'JH'
order by case
when role = 'SM'
then 0
else 1
end