I've spent several hours to make a "simple"
GROUP BY in Postgres without success. The
GROUP BY clause is giving me problems.
I have the table
cities with columns
user_id can be repeated, so the table can have this information:
"Bill", "New York" "Bill", "Chicago" "Adam", "New York" "Mike", "Los Angeles" ...
If I would like to have the count of cities it could be make this way:
SELECT cities.city, COUNT(*) FROM cities GROUP BY cities.city
But if I want to have this count and take only one city per user (it doesn't matter if "Bill" takes "New York" or "Chicago") how could I group by cities.user_id?