Skip to content

Instantly share code, notes, and snippets.

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 kovid-r/0262a95dbde4e263a08e8ed8494e687e to your computer and use it in GitHub Desktop.
Save kovid-r/0262a95dbde4e263a08e8ed8494e687e to your computer and use it in GitHub Desktop.
Sequence Window Functions Example
select p.name,
s.name,
s.gm,
row_number() over (partition by p.id order by s.gm) sat_rownum_by_sat_mass,
rank() over (partition by p.id order by s.gm) sat_rank_by_sat_mass,
dense_rank() over (partition by p.id order by s.gm) sat_dense_rank_by_sat_mass
from devstronomy.satellite as s right join
devstronomy.planet as p
on p.id = s.planet_id
where p.name = 'Jupiter';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment