[dba-SQLServer] Count by state

JWColby jwcolby at colbyconsulting.com
Sat Feb 3 08:32:29 CST 2007


I have a query where I need to count records by state.  I use the groupby
and count and voila.  The problem is that I need every state, whether or not
there is a record (give me a null or a zero), and I need it DOWN the page,
not across the page, i.e. it is going into a spreadsheet as a set of rows,
one row per state.  I will be doing comparisons with other counts where each
count will show up in a different set of states.  I always need all the
states represented in every count.  I know I can do that with the transform,
but that also turns it into columns and I need it kept in rows.
 
Any suggestions?
 
John W. Colby
Colby Consulting
www.ColbyConsulting.com
 



More information about the dba-SQLServer mailing list