[dba-SQLServer] Any easy way to do this?

jwcolby jwcolby at colbyconsulting.com
Mon Apr 12 11:28:29 CDT 2010


My client is constantly asking for "table counts" by which I mean filling in a table that looks kind 
of like a crosstab (but isn't) but for 4 or 5 vertical fields for 4 or 5 horizontal fields.

	FieldK	FieldL	FieldX	FieldZ
FieldA	Cnt?	Cnt?	?	?
FieldB	etc	etc
FieldC
FieldD

This isn't even a groupby since we are not talking values inside of FieldA, but rather a total count 
WHERE Field In ('X','Y','Z') and Field K is not null (or something similar).

This is just killing me in terms of time to complete this as the only way I am thinking of is to 
create 16 count queries.

Is there a better way?

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-SQLServer mailing list