Advertisement
Step8rother

Подзапросы в WHERE, задача 4

Jun 27th, 2023
1,910
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.35 KB | Source Code | 0 0
  1. --Отберите десять самых коротких по продолжительности треков и выгрузите названия их жанров.
  2.  
  3. SELECT name
  4. FROM genre
  5. WHERE genre_id IN
  6.     (SELECT DISTINCT(genre_id)
  7.      FROM
  8.        (SELECT genre_id
  9.         FROM track
  10.         ORDER BY milliseconds
  11.         LIMIT 10) AS sub);
Advertisement
Comments
  • t7235
    1 year
    # text 0.25 KB | 0 0
    1. необходимо добавить псевдонимы
    2.  
    3. SELECT g.name
    4. FROM genre AS g
    5. JOIN track AS t ON g.genre_id = t.genre_id
    6. WHERE t.track_id IN
    7. (SELECT track_id
    8. FROM track
    9. ORDER BY milliseconds
    10. LIMIT 2)
    11. ORDER BY t.milliseconds;
Add Comment
Please, Sign In to add comment
Advertisement