select paymentno,amount, case when amount>0 and amount40 and amount80 then 'high' else 'incorrect' end lvlfrom `penalties`.#对罚款登记分为三类,第一类low,包括大于0小于等于40的罚款,第二类moderate大于40...
mysql判断字段为零,返回空字符串
select paymentno,amount, case when amount>0 and amount<=40 then 'low' when amount>40 and amount<=80 then 'moderate' when amount>80 then 'high' else 'incorrect' end lvlfrom `penalties`.#对罚款登记分为三类,第一类low,包括大于0小于等于40的罚款,第二类moderate大于40 #到80之间的罚款,第三类high包含所有大于80的罚款。
同理查询是否为0 也可用 case when ,
select *** case when ***=0 then '' else '***' end lvl form ****
2014-03-18