Created
January 9, 2015 17:30
-
-
Save p5k6/c15cbb396854fe1af308 to your computer and use it in GitHub Desktop.
I think this would work?
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 * from ( | |
SELECT shows.* , ROW_NUMBER() OVER(PARTITION BY e.show_id ORDER BY e.airs_on) AS r | |
FROM episodes e | |
join shows s on s.id=e.show_id | |
WHERE e.airs_on >= NOW() | |
) a | |
where r=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment