isames
asked on
SQL Case Statement
I have a column called group number. We have several group numbers. Too many to list in a cast statement.
I have one column where I want to sum all group numbers in my Business Intelligence Software.
I used the following logic when I wanted sum just a few group numbers. I create what software calls a calculated field, and then I formatted it for SUM. This one works:
case
when NATIONAL_ACCOUNTS.group_nb r in ('03','04','04FT','05','05 FT','05FT2 ','08','08 FT','12',' 07')
then 1
Else 0
End)
Now I want to do the same thing for any group number (too many to list). I used the same logic, but changed it a little. It does not work. When I format the Calculated field to SUM, it shows 0:
case
when NATIONAL_ACCOUNTS.group_nb r in '*'
then 1
Else 0
End)
W
I have one column where I want to sum all group numbers in my Business Intelligence Software.
I used the following logic when I wanted sum just a few group numbers. I create what software calls a calculated field, and then I formatted it for SUM. This one works:
case
when NATIONAL_ACCOUNTS.group_nb
then 1
Else 0
End)
Now I want to do the same thing for any group number (too many to list). I used the same logic, but changed it a little. It does not work. When I format the Calculated field to SUM, it shows 0:
case
when NATIONAL_ACCOUNTS.group_nb
then 1
Else 0
End)
W
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Paul.
I actually tried the Count function before posting this, and it allowed me to see a total at the grouping level, but not an over-all total.
I actually tried the Count function before posting this, and it allowed me to see a total at the grouping level, but not an over-all total.
or you could just count instead
COUNT(NATIONAL_ACCOUNTS.gr
COUNT() does not increment for a NULL value