WITH au AS (SELECT COUNT(Id) all_users FROM Users), p AS ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

WITH au AS
(SELECT COUNT(Id) all_users
 FROM Users),
p AS
(SELECT OwnerUserId, COUNT(*) posts
 FROM Posts
 GROUP BY OwnerUserId)
SELECT u.Id, p.OwnerUserId, 
COALESCE(p.posts, 0) count_posts,
(CASE WHEN p.posts IS NULL THEN '1_without_post' END) category
FROM Users u
LEFT JOIN p ON p.OwnerUserId = u.Id
ORDER BY count_posts desc, u.Id OFFSET 0 ROW FETCH NEXT 20 ROWS ONLY;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results