Link to home
Start Free TrialLog in
Avatar of isames
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_nbr in ('03','04','04FT','05','05FT','05FT2','08','08FT','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_nbr in '*'
then 1
Else 0
End)

W
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FYI:
or you could just count instead

COUNT(NATIONAL_ACCOUNTS.group_nbr)

COUNT() does not increment for a NULL value
Avatar of isames
isames

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.