Skip to content

Instantly share code, notes, and snippets.

@RedaAffane
Last active February 21, 2018 11:28
Show Gist options
  • Save RedaAffane/bb45afa3294eac21c99dd2cb55bb7556 to your computer and use it in GitHub Desktop.
Save RedaAffane/bb45afa3294eac21c99dd2cb55bb7556 to your computer and use it in GitHub Desktop.
SELECT
*,
extract(epoch FROM "timestamp")
- lag(
extract(epoch from "timestamp")
) over (
PARTITION BY "user_id"
order by "timestamp"
) as "time_difference"
FROM log_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment