Screen Link: https://app.dataquest.io/m/2000603/nested-and-correlated-subqueries-assessment/5/question-5
My code so far:
SELECT at.title
FROM (SELECT *
FROM track t
JOIN album a
ON t.album_id = a.album_id) AS at
WHERE NOT EXIST (SELECT *
FROM invoice_line i
WHERE at.track_id = i.track_id);
What I expected to happen:
A query that display all albums that have tracks that have never been sold.
What actually happened:
OperationalError: near "SELECT": syntax error
An alternative query I tried that gives the same error:
SELECT title
FROM album a
WHERE album_id IN (SELECT album_id
FROM track t
WHERE NOT EXIST (SELECT *
FROM invoice_line i
WHERE t.track_id = i.track_id));
Can you please help me out with this, explain the logic behind the code? What am I doing wrong? This exercise is driving me crazy. The lack of feedback and solution at the end got me stuck in a endless loop of trial and error.