Dina_J

hzchto

Dec 4th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  WITH post_count AS
  2. (SELECT      
  3.     p.user_id AS user_id,
  4.     u.display_name as name,
  5.     COUNT(p.id )AS post_count
  6. FROM stackoverflow.users AS u
  7. INNER JOIN stackoverflow.posts AS p ON p.user_id = u.id
  8. INNER JOIN stackoverflow.post_types AS pt ON pt.id = p.post_type_id
  9.  
  10. WHERE pt.type = 'Answer' AND DATE_TRUNC('day', p.creation_date) <= DATE_TRUNC('day', u.creation_date) + INTERVAL '1 month'
  11. GROUP BY user_id, u.display_name
  12. HAVING COUNT(p.id) > 100
  13. ORDER BY  u.display_name)
  14.  
  15.  
  16. SELECT pc.name, COUNT(pc.user_id) AS ucount
  17. FROM post_count as pc
  18. GROUP BY pc.name
  19. ORDER BY pc.name
Advertisement
Add Comment
Please, Sign In to add comment