Skip to content

Instantly share code, notes, and snippets.

@gitcheckoutnikhil
Last active April 13, 2018 17:35
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 gitcheckoutnikhil/d054f0d063572bb24c0365eb7b855533 to your computer and use it in GitHub Desktop.
Save gitcheckoutnikhil/d054f0d063572bb24c0365eb7b855533 to your computer and use it in GitHub Desktop.
window function
--first value
first_value(country_id)
over(partition by user_id order by row_date
rows between unbounded preceding and unbounded following) as country_id,
--rank
rank()
over(partition by user_id order by view_date) as rank,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment