Created
February 15, 2016 23:10
-
-
Save itsam/1f113bab4d2172b23a26 to your computer and use it in GitHub Desktop.
Get IMC statistics for intervals to measure performance
This file contains 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 AVG(days_diff) AS avg_days, MIN(days_diff) AS min_days, MAX(days_diff) AS max_days, COUNT(issueid) AS count_issues,stepid, s.title AS steptitle, s.stepcolor,catid, c.title AS category | |
FROM | |
( | |
SELECT DISTINCT * FROM ( | |
SELECT a.issueid, a.stepid, b.catid, a.created, | |
CASE WHEN (a.created - f.created) IS NULL THEN a.created + INTERVAL 1 SECOND ELSE f.created END AS vcreated, | |
CASE WHEN (a.created - f.created) IS NULL THEN 0 ELSE ABS(DATEDIFF(a.created, f.created)) END AS days_diff | |
FROM scsue_imc_log AS a | |
LEFT JOIN scsue_imc_log AS f ON a.created > f.created AND a.issueid = f.issueid | |
LEFT JOIN scsue_imc_issues AS b ON b.id = a.issueid | |
WHERE a.issueid IN ( | |
SELECT id | |
FROM scsue_imc_issues AS p | |
WHERE p.state = 1 | |
AND p.stepid <> 1 | |
) | |
AND a.action = "step" | |
AND a.state = 1 | |
GROUP BY vcreated | |
) AS dis | |
GROUP BY issueid | |
) AS intervals | |
LEFT JOIN scsue_imc_steps AS s ON s.id = intervals.stepid | |
LEFT JOIN scsue_categories AS c ON c.id = intervals.catid | |
GROUP BY catid, stepid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment