Q&A for linguists, teachers, and students wanting to discuss the finer points of the Latin language
DECLARE @Start datetime ='2013-01-01'; DECLARE @End datetime ='2013-01-08'; SELECT SUM(CASE WHEN (a.Score > 0 AND q.AcceptedAnswerId>0) THEN 1 ELSE 0 END) Accepted, --^^Why not needed??? COUNT(*) Total, SUM(CASE WHEN a.Score > 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(*) Perc FROM Posts q LEFT JOIN Posts a ON q.AcceptedAnswerId = a.Id WHERE q.ClosedDate BETWEEN @Start AND @END