我已经成功地完成了以下查询:
SELECT rs.personid, rs.rec_count,
sum(case when r.rectype = 'degreeOne' then 1 else 0 end)
但是现在我想把它改成
SELECT rs.personid, rs.rec_count,
sum(case when r.rectype = 'test1' then 1 else 0 end) OR sum(case when r.rectype = 'random' and r.badgeid = 'bronze' then 1 else 0 end) as degree_one, ...
基本上我想用"OR"
运算符做sum,我试过了,但它给了我一个错误。
sum (
case
when
r.rectype = 'test1'
or
r.rectype = 'random' and r.badgeid = 'bronze'
then 1
else 0
end
) as degree_one