Q&A for scientists using computers to solve scientific problems
DECLARE @Reputation int = ##Reputation## SET NOCOUNT ON SELECT Q.Id, Sum(IIF(U.Reputation >= @Reputation, 1, 0)) As HighRepAnswers, Sum(IIF(U.Reputation < @Reputation, 1, 0)) AS LowRepAnswers INTO #RepAnswers FROM Posts AS Q LEFT JOIN (Posts AS A INNER JOIN Users AS U ON A.OwnerUserId=U.Id) ON A.ParentId=Q.Id WHERE Q.ParentID Is Null AND Q.CreationDate > DateAdd(m, -1, GETDATE()) GROUP BY Q.Id GO SELECT 'Questions total' AS [Column], Count(Id) as [Number] FROM #RepAnswers UNION SELECT 'Questions with 0 answers' AS [Column], Count(Id) AS [Number] FROM #RepAnswers WHERE HighRepAnswers=0 and LowRepAnswers=0 UNION SELECT 'Questions with 1 or more High-rep answer' AS [Column], Count(Id) AS [Number] FROM #RepAnswers WHERE HighRepAnswers>=1