Here's another SQL statement I find useful every now and then, and not necessarily intuitive enough to remember. This will return a list of people (for instance), with the people with the most records at the top. Great for rankings, etc.
SELECT person, COUNT(*) AS number_of_records
FROM people
GROUP BY person
ORDER BY number_of_records DESC;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment