Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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