Created
January 8, 2013 21:23
-
-
Save rlr/4488088 to your computer and use it in GitHub Desktop.
SQL for questions answered in 72hours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
(extract( year from created )) AS `year`, | |
(extract( day from created )) AS `day`, | |
(extract( month from created )) AS `month`, | |
COUNT(`questions_question`.`created`) AS `count` | |
FROM `questions_question` | |
INNER JOIN `auth_user` | |
ON (`questions_question`.`creator_id` = `auth_user`.`id`) | |
WHERE (`auth_user`.`is_active` = 1 | |
AND `questions_question`.`created` >= '2011-01-01 00:00:00' | |
AND `questions_question`.`id` | |
IN (SELECT U0.`question_id` FROM `questions_answer` U0 INNER JOIN `questions_question` U1 ON (U0.`question_id` = U1.`id`) WHERE U0.`created` < (U1.`created` + INTERVAL '3 0:0:0:0' DAY_MICROSECOND))) | |
GROUP BY | |
(extract( year from created )), | |
(extract( day from created )), | |
(extract( month from created )) | |
ORDER BY `questions_question`.`updated` DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment