WITH badges_cte AS( SELECT DISTINCT(UserId), CASE WHEN Us...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

WITH badges_cte AS( SELECT DISTINCT(UserId),
			CASE WHEN UserId IS NOT NULL THEN
				1
			ELSE
				0
			END AS 'has_badges'
		FROM
			Badges
)
SELECT
	TOP (50) *
FROM
	Posts p
	INNER JOIN Users u ON p.OwnerUserId = u.Id
	INNER JOIN badges_cte b ON u.Id = b.UserId
WHERE
	YEAR(ClosedDate) = 2021
	AND MONTH(ClosedDate) = 09
	AND PostTypeId = 1
ORDER BY
	Score DESC

Enter Parameters

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