jhanlon homework W6Q1

0

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

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

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results