在编写sql的时候,需要查询某一列大于0的次数,本来直接写的是如下
select count(score >0)scoreNum from student,但是发现统计出来的结果不对,
查阅资料资料后改为下列即可
select count(CASE WHEN ColumnA = 0 THEN 1 END) scoreNum from student;
在编写sql的时候,需要查询某一列大于0的次数,本来直接写的是如下
select count(score >0)scoreNum from student,但是发现统计出来的结果不对,
查阅资料资料后改为下列即可
select count(CASE WHEN ColumnA = 0 THEN 1 END) scoreNum from student;