I'm having a hard time counting entries in SQL database. I need to count all entries of the same value in a row. Counting entries in a column down I got no problem with but can't seem to get the row count right. Please can someone help?
Name | Day1 | Day2 | Day3 |
---|---|---|---|
Name 1 | D | D | N |
Name 2 | D | N | N |
Name 3 | D | D | D |
Name 4 | N | D | D |
Example:
Select count(Day1) as [Day Shift]
from MyTable
where Day1 = 'D'
Result: 3
I need to count Name1 D's. Result must be Name1 = 2.
Pleas can someone help?
Thank you in advance.
Mel
This SQL:
select count(case when Day1 = 'D' then 1 else null end) as [Off Days]
from mYtABLE
still returns the same result.