JIRA DB query to get status of all issues on a previous date

select newvalue,issueid,created from jiraschema.changegroup,jiraschema.changeitem
where changegroup.created < '02/05/2013' AND
changeitem.GROUPID = changegroup.ID
)as CH1
left outer join (
select newvalue,issueid,created from jiraschema.changegroup,jiraschema.changeitem
where changegroup.created < '02/05/2013' AND
changeitem.GROUPID = changegroup.ID
) as
 CH2
on (CH1.issueid = CH2.issueid and CH1.created < CH2.created)
where CH2.issueid is null

This is what I'm using finding the max created date from changegroup table from the given date and getting the newvalue . THis gives some results , but missses out on issues which are created and no activity has been done as yet . Those will not be listed in this table and th eonly entry I find is in the assignee field with the new value as the username for the user .

1 answer

Hi Pushparaj,

I believe you can use the following query to help you achieve that:

SELECT JI.pkey, STEP.STEP_ID
FROM (SELECT STEP_ID, ENTRY_ID
      FROM OS_CURRENTSTEP
      WHERE OS_CURRENTSTEP.START_DATE < '<your date>'
UNION SELECT STEP_ID, ENTRY_ID
      FROM OS_HISTORYSTEP
      WHERE OS_HISTORYSTEP.START_DATE < '<your date>'
      AND OS_HISTORYSTEP.FINISH_DATE > '<your date>' ) As STEP,
(SELECT changeitem.OLDVALUE AS VAL, changegroup.ISSUEID AS ISSID
      FROM changegroup, changeitem
      WHERE changeitem.FIELD = 'Workflow'
      AND changeitem.GROUPID = changegroup.ID
UNION SELECT jiraissue.WORKFLOW_ID AS VAL, jiraissue.id as ISSID
      FROM jiraissue) As VALID,
jiraissue as JI
WHERE STEP.ENTRY_ID = VALID.VAL
AND VALID.ISSID = JI.id
AND JI.project = <proj_id>;

This query retrieves the status of all issues on a give date in a give project. You can find more query examples at: Example SQL Queries for JIRA

Hope this helps!

Cheers,

Clarissa.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,197 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot