Skip to content

Instantly share code, notes, and snippets.

@vincentdesmares
Created May 12, 2017 00:16
Show Gist options
  • Save vincentdesmares/ab48aa9b9059641f368f061372d08bfd to your computer and use it in GitHub Desktop.
Save vincentdesmares/ab48aa9b9059641f368f061372d08bfd to your computer and use it in GitHub Desktop.
SELECT *
FROM (
SELECT
*,
row_number()
OVER ordered_report_by_category
FROM
employe
WINDOW ordered_report_by_category AS (
PARTITION BY
category
ORDER BY
salary DESC
RANGE
BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING
)
) tmp
WHERE
row_number <= 2
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment