I am trying to query how many songs on average are on albums with the word "Rock" in the title. The chosen albums must have at least eight songs on them.
SELECT AVG(tr.track_id)
FROM (SELECT al.album_id AS album,
tr.name,
COUNT(tr.track_id)
FROM track as tr
LEFT OUTER JOIN album as al ON al.album_id = tr.album_id
WHERE tr.name LIKE '%Rock%'
GROUP tr.name
) AS ag
HAVING COUNT(al.album_id) >= 8;