[dba-SQLServer] You'll love this!

Gustav Brock Gustav at cactus.dk
Wed Sep 22 01:23:07 CDT 2010


Hi John

Why not write the list of those 20+ zip items to a temp table, then join this with your table to update?

/gustav


>>> jwcolby at colbyconsulting.com 22-09-2010 06:28 >>>
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