Advertisement
AliaksandrLet

Reviewed flags of top videos solution

May 24th, 2022
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.53 KB | None | 0 0
  1. -- Reviewed flags of top videos
  2. -- https://platform.stratascratch.com/coding/2103-reviewed-flags-of-top-videos
  3. SELECT
  4.     video_id,
  5.     COUNT(flag_review.reviewed_by_yt)
  6. FROM
  7.     user_flags
  8.     INNER JOIN flag_review ON flag_review.flag_id = user_flags.flag_id
  9. GROUP BY
  10.     video_id
  11. HAVING
  12.     COUNT(video_id) = (
  13.         SELECT
  14.             MAX(Count)
  15.         FROM (
  16.             SELECT
  17.                 COUNT(*) AS Count
  18.             FROM
  19.                 user_flags
  20.                 INNER JOIN flag_review ON flag_review.flag_id = user_flags.flag_id
  21.             GROUP BY
  22.                 video_id
  23.         ) AS CntList
  24.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement