My boss is asking me to code a report that has the following components:
- A pie chart of employee count by state
- A pie chart of employee count by age bracket (10 year brackets)
- A pie chart of employee length of service (5 year brackets)
- A pie chart of employee Male/Female breakdown
- A pie chart of employee count by salary band (computer generates brackets).
There may be others.
I know I can do this by writting 5 different sql statements. However it seems like this would generate 5 table scans for one report.
I could switch gears and do one table scan and analyse each record on the front end and increment counters and probably accomplish this with one-pass.
Which way would the collective wisdom at stackoverflow go on this?
Is there a way to accomplish this with the CUBE or ROLL UP clauses in T-SQL?