I am trying to count the number of rows in a table where a condition is true.
My query is:
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
I keep reading other posts but can't find an answer to this issue.
The query that you have does not look correct and you can not count this way. However you can do something as
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
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments