Skip to content

Instantly share code, notes, and snippets.

@belsrc
Created January 12, 2016 15:09
Show Gist options
  • Save belsrc/fad19c307451d48190a5 to your computer and use it in GitHub Desktop.
Save belsrc/fad19c307451d48190a5 to your computer and use it in GitHub Desktop.
Get total for each distinct value query
-- Get a count of people in each city from a specific state
SELECT DISTINCT(city) AS city, COUNT(city) AS total
FROM data
WHERE state = ?
GROUP BY city
ORDER BY city ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment