SQL RANK

SQL

https://www.codewars.com/kata/58094559c47d323ebd000035/train/sql

SELECT p.id, 
        p.name, 
        COUNT(s.sale) sale_count,
        RANK () OVER ( 
            ORDER BY COUNT(s.sale) DESC
          ) sale_rank
FROM people p JOIN sales s ON p.id=s.people_id
GROUP BY p.id, p.name
Did you find this snippet useful?

Sign up for free to to add this to your code library

median
SQL

5
EXISTS
SQL

4