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
FROM Users u
LEFT JOIN p ON p.OwnerUserId = u.Id
ORDER BY count_posts, 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