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;
Tuesday, June 30, 2009
Subscribe to:
Posts (Atom)