ourlang

第一种、通过count和if判断来统计

select
COUNT(*) AS total,
COUNT(if( mdt_apply_type=\'1\' ,1,NULL) )as singleDiseasesNum,
COUNT(if( mdt_apply_type=\'2\' ,1,NULL) )as multidisciplinaryNum
from t_mdt_apply_list b WHERE 1=1 AND audit_opinion=\'3\'

查询效果如下:
在这里插入图片描述
第二种、通过sum和if判断来统计

select
COUNT(*) AS total,
SUM(if( mdt_apply_type=\'1\' ,1,0) )as singleDiseasesNum,
SUM(if( mdt_apply_type=\'2\' ,1,0) )as multidisciplinaryNum
from t_mdt_apply_list b WHERE 1=1 AND audit_opinion=\'3\'

查询效果如下:
在这里插入图片描述

分类:

技术点:

相关文章: