我正在尝试计算条件为真的表中的行数。
我的查询是:
SELECT
COUNT(SeqID0101),
COUNT(SeqID0102),
COUNT(SeqID0103),
COUNT(SeqID0104),
COUNT(SeqID0105),
COUNT(SeqID0106),
COUNT(SeqID0107),
COUNT(SeqID0108),
COUNT(SeqID0109),
COUNT(SeqID0110)
FROM
PH001_Hist
WHERE
SeqID0101 = 1 OR SeqID0102 = 1 OR OR SeqID0103 = 1 OR SeqID0104 = 1 OR SeqID0105 = 1
OR SeqID0106 = 1 OR SeqID0107 = 1 OR SeqID0108 = 1 OR SeqID0109 = 1 OR SeqID0110 = 1
我一直在阅读其他帖子,但无法找到这个问题的答案,有人可以帮忙。
非常感谢,
DCJ
答案 0 :(得分:0)
您拥有的查询看起来不正确,您不能这样计算。但是你可以做一些事情
select
sum(SeqID0101 = 1) as SeqID0101,
sum(SeqID0102 = 1) as SeqID0102,
sum(SeqID0103 = 1) as SeqID0103,
sum(SeqID0104 = 1) as SeqID0104,
sum(SeqID0105 = 1) as SeqID0105,
sum(SeqID0106 = 1) as SeqID0106,
sum(SeqID0107 = 1) as SeqID0107,
sum(SeqID0108 = 1) as SeqID0108,
sum(SeqID0109 = 1) as SeqID0109,
sum(SeqID0110 = 1) as SeqID0110
from
PH001_Hist
答案 1 :(得分:0)
select
sum(SeqID0101) as SeqID0101,
sum(SeqID0102) as SeqID0102,
sum(SeqID0103) as SeqID0103,
sum(SeqID0104) as SeqID0104,
sum(SeqID0105) as SeqID0105,
sum(SeqID0106) as SeqID0106,
sum(SeqID0107) as SeqID0107,
sum(SeqID0108) as SeqID0108,
sum(SeqID0109) as SeqID0109,
sum(SeqID0110) as SeqID0110
from
PH001_Hist