Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to pull two customers from each city

I am having a very difficult time determining how to write a query (subquery)
that is able to pull the top two accounts from each city/state based on criteria.
Top 2 will obviously only return the top 2 customer accounts, but I need
the top two for EACH of the 9773 cities we have in our tables.

To get by today, I wrote a cursor that took 20 minutes to extract 16,000
records but I know there is a way to do this in a simple query. Racking the
ole braing trying to get the syntax correct!!

Any ideas are GREATLY appreciated..

Derek
[579 byte] By [Derek Randles] at [2007-11-9 21:11:29]