Skip to content

Instantly share code, notes, and snippets.

@andrewscaya
Created November 4, 2016 19:48
Show Gist options
  • Select an option

  • Save andrewscaya/89eaddccf7ccc7218e73a2daf912137c to your computer and use it in GitHub Desktop.

Select an option

Save andrewscaya/89eaddccf7ccc7218e73a2daf912137c to your computer and use it in GitHub Desktop.
SELECT
event_id,
date - lag(date) OVER (PARTITION BY event_id ORDER BY date) as difference
FROM
events;
SELECT
dept,
name,
salary,
AVG(salary) as avg_salary OVER (PARTITION BY dept)
FROM
employees;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment