[dba-SQLServer] Count by state

Susan Harkins ssharkins at setel.com
Sat Feb 3 09:16:51 CST 2007


John, a few things about Count():

1.) Count(fld) won't consider Nulls -- are your states with no values, Null
or 0?
2.) Count(*) will count all rows. 

Susan H. 

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
 
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.14/657 - Release Date: 1/29/2007
9:04 AM
 




More information about the dba-SQLServer mailing list