Skip to content

Instantly share code, notes, and snippets.

@cweagans
Created January 21, 2012 03:48
Show Gist options
  • Save cweagans/1651178 to your computer and use it in GitHub Desktop.
Save cweagans/1651178 to your computer and use it in GitHub Desktop.
SELECT
pic.nid,
pic.sid as "original_state",
pis.name as "original_state_name",
pic.comment_number,
(
SELECT
pic2.sid
FROM
project_issue_comments pic2
WHERE
pic2.nid = 1360994 AND
pic2.comment_number = pic.comment_number + 1
) as "new_state",
(
SELECT
pis2.name
FROM
project_issue_state pis2
WHERE
pis2.sid = new_state
) as "new_state_name",
pic.timestamp
FROM
project_issue_comments pic
JOIN
project_issue_state pis ON pic.sid = pis.sid
WHERE
pic.nid = 1360994;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment