Skip to content

Instantly share code, notes, and snippets.

@cweagans
Created January 21, 2012 06:06
Show Gist options
  • Save cweagans/1651625 to your computer and use it in GitHub Desktop.
Save cweagans/1651625 to your computer and use it in GitHub Desktop.
SELECT
pic.nid,
(
SELECT
pic2.sid
FROM
project_issue_comments pic2
WHERE
pic2.nid = pic.nid AND
pic2.comment_number = pic.comment_number - 1
) as "original_state",
(
SELECT
pis2.name
FROM
project_issue_state pis2
WHERE
pis2.sid = original_state
) as "original_state_name",
pic.sid as "new_state",
pis.name as "new_state_name",
pic.comment_number,
pic.timestamp,
n.created,
(pic.timestamp - n.created) as time_difference
FROM
project_issue_comments pic
JOIN
project_issue_state pis ON pic.sid = pis.sid
JOIN
node n ON n.nid = pic.nid
GROUP BY
n.nid
HAVING
`original_state` = 8 AND
`new_state` = 13
ORDER BY
pic.nid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment