Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH popular_movies (movie_id, torrent_count) AS (
- SELECT
- movie_id,
- "count" (*)
- FROM
- torrents
- WHERE
- movie_id IS NOT NULL
- GROUP BY
- movie_id
- ORDER BY
- "count" (*) DESC
- LIMIT 10
- )
- SELECT
- top_size.title, top_size.SIZE, top_size.info_hash
- FROM
- popular_movies pm
- JOIN LATERAL (
- SELECT
- *
- FROM
- torrents tt
- WHERE
- tt.movie_id = pm.movie_id
- ORDER BY
- tt. SIZE DESC
- LIMIT 10
- ) top_size ON (TRUE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement