>Hi. I have a database with customer #'s and zip codes (among other things). How would I do a SQL to give me a report of unique zip codes and unique customer numbers within that zip code.
>
>I can get a listing with unique zips, but it gives me a count of all customers (not ignoring repeat customers).
>
>Thanks, Randy
Select Count(*) as CntDups, Zip, CustomerID ;
from MyTable group by 2,3 having CntDups > 1 into cursor curDups
select * from MyTable my inner join curDups dup on my.Zip = dup.zip and my.CustomerID = dup.CustomerID
Of course, these two selects can be combined into one.
For unique codes change condition to CntDups = 1 and the cursor name to curUnique
UPDATE. Looks like I misunderstood your requirements and Sergey got it right.
If it's not broken, fix it until it is.
My Blog