Guest User

Untitled

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