Q&A for scientists using computers to solve scientific problems
with postscounts_cte AS ( SELECT u.Id AS uid, COUNT(p.Id) as cnt FROM Users u INNER JOIN Posts p ON p.OwnerUserId=u.Id WHERE (p.PostTypeId IN (##types?1,2##)) GROUP BY u.Id ) ---1=questions ---2=answers ---1,2=both questions and answers SELECT TOP(##num?100##) uid AS [User Link], 'site://users/' + CAST(uid AS varchar)+'/badges' AS [Link] FROM Badges b INNER JOIN postscounts_cte u ON b.UserId=u.uid WHERE (b.Name = '##name?Great Answer##') AND (u.cnt=1) ORDER BY b.Date