I've a database of musical tracks, and I'm trying to find which genre has the most tracks. Genre is stored in a Work table, with each track in the Track table having a field for which Work it belongs to.
This query correctly returns the genres and how many tracks they each have:
SELECT w.genre
, COUNT(t.name) [numTracks]
FROM Track t
LEFT
JOIN Work w
ON t.workName = w.name
LEFT
JOIN AlbumContains ta
ON ta.workName = t.workName
GROUP
BY w.genre
But I can't find a way to just take whichever genre (or multiple genres) has the highest numTracks from that result.
Thanks in advance!