Skip to content

Instantly share code, notes, and snippets.

@Mr--John-Doe
Last active February 6, 2022 10:56
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/c6c4f2ad869316faf9720f853e02752f to your computer and use it in GitHub Desktop.
Save Mr--John-Doe/c6c4f2ad869316faf9720f853e02752f to your computer and use it in GitHub Desktop.
WITH base as (
SELECT *
, LAG(login_date) OVER (PARTITION BY username ORDER BY date) AS previous_login_date
FROM sales_site.login
)
SELECT *
FROM base
WHERE login_date between $FROM_DATE and $TO_DATE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment