Skip to content

Instantly share code, notes, and snippets.

@Mr--John-Doe
Created December 9, 2021 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr--John-Doe/6c9009b379adb02251ca3141520af600 to your computer and use it in GitHub Desktop.
Save Mr--John-Doe/6c9009b379adb02251ca3141520af600 to your computer and use it in GitHub Desktop.
windows function - basics - example#2
WITH agg AS (
SELECT depname, AVG(salary) avg_salary
FROM empsalary
GROUP BY depname
)
SELECT depname, empno, salary, avg_salary
FROM empsalary
INNER JOIN agg
USING (depname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment