关于sql语句里根据状态显示对应信息
1, case..when...then..
例:select a.id,(case a.station where 0 then "正常"
where 1 then "异常"
else "未统计入库"
end
) 状态 from factory a;
2, IF(expr1,expr2,expr3)
例:
SELECT IF(a.sex=1,"男","女") AS s FROM table a WHERE sex != '';
3, count(case when expr1 then 1 end)arg1
select count(case when a.ststion=0 then 1 end)正常,
count(case when a.station=1 then 1 end)异常,
count(case when a.station<>0 and a.station<>1 then 1 end ) 未统计入库
from table a;