Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Посчитайте для каждого года число уникальных названий купленных треков.
- SELECT EXTRACT(YEAR FROM CAST(i.invoice_date AS DATE)) AS year_of_invoice,
- COUNT(DISTINCT t.name) AS unique_track_count
- FROM track AS t
- LEFT JOIN invoice_line AS il ON t.track_id = il.track_id
- LEFT JOIN invoice AS i ON il.invoice_id = i.invoice_id
- GROUP BY year_of_invoice;
Advertisement
Comments
-
- привет. в полученном результате выдает ошибку - слишком много строк.
-
- в седьмой строке LEFT на RIGHT поменять надо
-
- либо немного изменить
- SELECT EXTRACT(YEAR FROM CAST(i.invoice_date AS DATE)) AS year_of_invoice,
- COUNT(DISTINCT t.name) AS unique_track_count
- FROM invoice AS i
- LEFT JOIN invoice_line AS il ON i.invoice_id = il.invoice_id
- LEFT JOIN track AS t ON il.track_id = t.track_id
- GROUP BY year_of_invoice;
Add Comment
Please, Sign In to add comment
Advertisement