Created
January 12, 2016 15:07
-
-
Save belsrc/7a190327b5122dea93e2 to your computer and use it in GitHub Desktop.
Totals per starting letter query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get a count of, lets say, people's names that start with each letter | |
-- from a specific city and state | |
SELECT LEFT(name, 1) AS letter, COUNT(id) AS total | |
FROM data_table | |
WHERE city = ? AND state = ? | |
GROUP BY letter | |
ORDER BY letter ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment