0
我想在90算分数,但这个结束了。如果我的数据是如何计算分数超过90 SQL
100
45
90
100
它应该显示3总行
select g.score as score
,count(case when g.score>=90 then 1 else 0 end) over() as passed
from grades g
计数,而是它显示4
我想在90算分数,但这个结束了。如果我的数据是如何计算分数超过90 SQL
100
45
90
100
它应该显示3总行
select g.score as score
,count(case when g.score>=90 then 1 else 0 end) over() as passed
from grades g
计数,而是它显示4
你要么删除ELSE
一部分,所以默认为NULL和COUNT
犯规次数NULL
select g.score as score
,count(case when g.score>=90 then 1 end) over() as passed
from grades g
或更改COUNT
为SUM
select g.score as score
,SUM(case when g.score>=90 then 1 else 0 end) over() as passed
from grades g
只需在SUM
编辑COUNT
。 COUNT
计数非空值,所以它甚至计数0; SUM
只会'计数'非零值
谢谢大声笑不,我没有喝水,我gu it着它 – user1854438