Advertisement
kieni17

Untitled

Mar 31st, 2020
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.47 KB | None | 0 0
  1. SELECT p.id
  2. FROM posts p,
  3.      comments c,
  4.      users u,
  5.      badges b,
  6.     (SELECT creationdate, MAX(upvotes) AS maxUpVotes FROM users u WHERE u.creationdate > p.creationdate) AS sub1
  7.     (SELECT MAX(relatedpostid) AS maxrelatedpostid  FROM postlinks) AS s2
  8. WHERE  c.postid = p.id
  9.    AND u.id = p.owneruserid
  10.    AND c.creationdate = s1.creationdate
  11.    AND u.upvotes = s1.maxUpVotes
  12.    AND s2.maxrelatedpostid > p.id
  13.    AND u.id = b.userid
  14.    AND (b.name LIKE 'Research Assistant');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement