Advertisement
AlexanderDM

sortirovka?

Nov 26th, 2022
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH temple AS (SELECT user_id,
  2.                        COUNT (id) AS total
  3.                FROM stackoverflow.badges
  4.                WHERE creation_date::date BETWEEN '2008-11-15' AND '2008-12-16'
  5.                GROUP BY user_id)
  6.                
  7. SELECT DISTINCT user_id,
  8.        total,
  9.        RANK() OVER (ORDER BY total)
  10. FROM temple
  11. ORDER BY total DESC, user_id ASC
  12. LIMIT 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement