Advertisement
kieni17

Untitled

Apr 8th, 2020
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.46 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 GROUP BY u.creationdate) AS sub1,
  7.     (SELECT MAX(relatedpostid) AS maxrelatedpostid  FROM postlinks) AS sub2
  8. WHERE c.postid = p.id  AND u.id = p.owneruserid  AND u.id = b.userid
  9.   AND b.name LIKE 'Research Assistant'
  10.   AND u.upvotes = sub1.maxUpVotes
  11.   AND sub2.maxrelatedpostid > p.id;
  12.   AND sub1.creationdate > p.creationdate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement