Set-Aggregate Functions
SELECT
class_id,
percentile_cont(0.5) WITHIN GROUP (ORDER BY score) AS median_score
FROM grades
GROUP BY 1
ORDER BY 2 DESC;
SELECT
class_id,
percentile_cont(0.5) WITHIN GROUP (ORDER BY score) AS median_score
FROM grades
GROUP BY 1
ORDER BY 2 DESC;