mysql case when group by 实例详解 |
mysql 中类似php switch case 的语句 。
下面是一个分组求和示例: select sum(redpackmoney) as stota,ischeck from t_redpack group by isCheck 使用case when : select sum(redpackmoney) as stota, (CASE isCheck WHEN '1' THEN 'checktrue' WHEN '0' THEN 'uncheck' WHEN '-1' THEN 'checkfalse' ELSE 'unknow' END) as checkinfo from t_redpack group by isCheck checkinfo中 -1, 0, 1 替换为 checkfalse, uncheck, checktrue(CASE WHEN进行字符串替换处理) 以上就是mysql中case when语句的简单使用示例介绍 。 您可能感兴趣的文章:
|