Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT `image_ID`,`ID`,reddit_rank(`created` , `ups` , `downs`) AS rank
- FROM captions s1
- WHERE `image_ID` NOT IN
- (SELECT `image_ID` s2, FROM captions
- WHERE s1.`image_ID` = s2.`image_ID` and rank(s1.created, s1.ups, s1.downs) > rank(s2.created , s2.ups, s2.downs))
- ORDER BY rank DESC
- captions:
- ID image_ID created ups downs
- ---|---------|------------|--------|---------
- 1 | 10 | 04/03/2009 | 1000 | 399
- 2 | 11 | 04/03/2009 | 5600 | 244
- 5 | 12 | 04/03/2009 | 343 | 555
- 3 | 10 | 03/03/2009 | 4554 | 300
- 4 | 11 | 03/03/2009 | 100000 | 200
- 6 | 12 | 03/03/2009 | 777 | 500
- 7 | 13 | 24/12/2008 | 1 | 600
- 8 | 13 | 01/01/2009 | 0 | 700
Add Comment
Please, Sign In to add comment