WITH users_posts AS ( SELECT DISTINCT u.id, COUNT(*) AS p...

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Great Outdoors

Q&A for people who love being outdoors enjoying nature and wilderness, and learning about the required skills and equipment

WITH users_posts AS (
  SELECT DISTINCT u.id, COUNT(*) AS posts_amount
  FROM users AS u
  JOIN posts AS p
  ON u.id = p.owneruserid
  WHERE p.posttypeid = 1
  GROUP BY u.id
)
SELECT 'Users with less than 10 questions', COUNT(DISTINCT users_posts.id)
FROM users_posts
WHERE posts_amount < 10
UNION ALL
SELECT 'Users with less than 20 questions and more than 10', COUNT(*)
FROM users_posts
WHERE posts_amount >= 10 AND posts_amount <= 20
UNION ALL
SELECT 'Users with more than 20 questions', COUNT(*)
FROM users_posts
WHERE posts_amount > 20

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results