Hi every there, I find some help please for this query:
“Considering the average number of tracks among the releases published on CD, get the artists who have released only releases with more tracks than the average (the result must contain the artist’s name and release number and be sorted by descending release number) (write two versions of the query).”
Here is the answer but it does not work perfectly.
SELECT DISTINCT(A.NAME), R.id, R.id FROM track AS T
JOIN medium AS M ON T.MEDIUM = M.ID
JOIN medium_format AS MF ON M.FORMAT = MF.ID
JOIN "release" AS R ON M.RELEASE = R.ID
JOIN artist_credit AS AC ON R.ARTIST_CREDIT = AC.ID
JOIN artist_credit_name AS ACN ON AC.ID = ACN.ARTIST
JOIN artist AS A ON ACN.ARTIST = A.ID
WHERE MF.NAME LIKE 'CD' AND T.POSITION > ALL (SELECT AVG(T.POSITION) FROM TRACK AS T)
ORDER BY A.NAME DESC