Forum Moderators: open
-----------------------------------------------
SELECT DISTINCT City, StateFullName, Population
FROM _ZipCodeDatabase_US
WHERE Population > 20000
GROUP BY City, StateFullName, Population
-----------------------------------------------
This however, gives me duplicate Cities! I'm assuming this is because some cities have zipcodes with the same Population number attached to the row.
How do I ONLY select DISTINCT cities, even if a city has zipcodes with the same population number? I only want to return ONE of each City.
Any ideas?
Jeremy
SELECT City, StateFullName
FROM _ZipCodeDatabase_US
WHERE Population > 20000
GROUP BY City, StateFullName
OR
SELECT DISTINCT City, StateFullName
FROM _ZipCodeDatabase_US
WHERE Population > 20000
Since you are not displaying an aggregate function in the column list, the SELECT DISTINCT is more appropriate.