[dba-SQLServer] You'll love this!

jwcolby jwcolby at colbyconsulting.com
Tue Sep 21 23:28:33 CDT 2010


My client asked me to sum (give him a count of) the records in zips where the count in each zip is > 20.

No problem, do a count group by zip, where the count > 20.  This gives me a list of such zip codes. 
  Then build a sum on that base query.

No comes the not so cool part.  I will have to select my records only from zips where the count of 
records in a zip is >=20.

This may be easy, join the base query back to the table and update a field to a code, then select 
from the table where that code is set.

My fear is that the join will make the view non-updateable.  Which will leave me using a cursor?

We shall see.

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-SQLServer mailing list