Advertisement
kieni17

Untitled

Apr 4th, 2020
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.55 KB | None | 0 0
  1. SELECT p.id
  2. FROM posts p,
  3.      comments c,
  4.      users u,
  5.      badges b,
  6.     (SELECT u.creationdate, MAX(u.upvotes) AS maxUpVotes FROM users u, posts p1 WHERE u.id = p1.owneruserid AND  u.creationdate > p1.creationdate GROUP BY u.creationdate) AS sub1,
  7.     (SELECT MAX(relatedpostid) AS maxrelatedpostid  FROM postlinks) AS sub2
  8. WHERE  c.postid = p.id
  9.    AND u.id = p.owneruserid
  10.    AND c.creationdate = sub1.creationdate
  11.    AND u.upvotes = sub1.maxUpVotes
  12.    AND sub2.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