Created
May 17, 2020 15:30
-
-
Save kovid-r/b3c9c3fcb65be6cc853cf83dbec7550e to your computer and use it in GitHub Desktop.
LAST_VALUE doesn't work without specifying windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select distinct p.name, | |
first_value(s.name) over (partition by p.id order by s.gm desc, s.radius desc) biggest_satellite, | |
last_value(s.name) over (partition by p.id order by s.gm desc, s.radius desc) smallest_satellite | |
from devstronomy.planet as p | |
left join devstronomy.satellite as s | |
on p.id = s.planet_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment