I want to create a simple summary report in Reporting Services using age
, account
and age group
as follows:
SELECT AGE,COUNT(ACCOUNT)AS TOTALCASES,
'AGEGRP' =CASE WHEN AGE <=5 THEN 'AGE 0 TO 5'
WHEN AGE >=6 THEN 'AGE 6 AND OLDER'
END
FROM MAIN
GROUP BY 'AGEGRP'
When I run this in SQL Server Management Studio, I receive error message:
Msg 164, Level 15, State 1, Line 1 Each GROUP BY expression must contain
at least one column that is not an outer reference.
Can someone suggest a way to produce summarized data, counting account number, summarizing by age 0 to 5
and age 6 and older
?