G
Guest
Look at the following code:
SELECT LEFT(ZIP,3) AS ZIP3, COUNT (ZIPCODES.ZIP) AS COUNTOFZIP
FROM ZIPCODES
GROUP BY LEFT( ZIP,3)
UNION SELECT LEFT(ZIP,5) AS ZIP5, COUNT(ZIPCODES.ZIP) AS COUNTOFZIP
FROM ZIPCODES
GROUP BY LEFT(ZIP,5)
HAVING COUNT(ZIP) >15;
Here is what my output looks like:
ZIPCODE COUNT
005 150
007 300
017 100
01710 50
018 19
I have two problems. The count for the 5-digit zip (50) is also included in
the count for the 3-digit zip (100). Also I need the 5-digits listed
together and the 3-digits listed together. I have been working on this for
several days. This is as close as I have come to having the right numbers.
SELECT LEFT(ZIP,3) AS ZIP3, COUNT (ZIPCODES.ZIP) AS COUNTOFZIP
FROM ZIPCODES
GROUP BY LEFT( ZIP,3)
UNION SELECT LEFT(ZIP,5) AS ZIP5, COUNT(ZIPCODES.ZIP) AS COUNTOFZIP
FROM ZIPCODES
GROUP BY LEFT(ZIP,5)
HAVING COUNT(ZIP) >15;
Here is what my output looks like:
ZIPCODE COUNT
005 150
007 300
017 100
01710 50
018 19
I have two problems. The count for the 5-digit zip (50) is also included in
the count for the 3-digit zip (100). Also I need the 5-digits listed
together and the 3-digits listed together. I have been working on this for
several days. This is as close as I have come to having the right numbers.