'I need a count of each track sold in an album then display all album names and it's corresponding track name that has max count in sql
sales table shows how many of each track is sold. I need to count of each track sold album table shows album names common field is trackid I need album name, only track title that's sold max in that album and count of that track sold.
select al.title as album, t.name as track, max(s.sales)
from tracks t, albums al,
(select al.title as album, count(i.trackid) as sales
from albums al, tracks t, invoice_items i
where t.trackid = i.trackid and t.albumid = al.albumid
group by album)s
where t.albumid = al.AlbumId;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
