我已成功完成以下查询:
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"
运算符求和,我尝试过,但是它给了我一个错误。
答案 0 :(得分:1)
sum (
case
when
r.rectype = 'test1'
or
r.rectype = 'random' and r.badgeid = 'bronze'
then 1
else 0
end
) as degree_one