Skip to content

Instantly share code, notes, and snippets.

@vincentdesmares
Created May 12, 2017 00:14
Show Gist options
  • Save vincentdesmares/73f96e7fcc89e0edb78f22f255cd8a42 to your computer and use it in GitHub Desktop.
Save vincentdesmares/73f96e7fcc89e0edb78f22f255cd8a42 to your computer and use it in GitHub Desktop.
SELECT
*,
count(*)
OVER report_by_category AS count,
count(*)
OVER ordered_report_by_category AS ordered_count
FROM
employe
WINDOW
report_by_category AS (
PARTITION BY
category
),
ordered_report_by_category AS (
PARTITION BY
category
ORDER BY
salary
RANGE
BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING
)
LIMIT 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment