JIRA query\sql to find first time closed issues on certain date.

Hi,

What't the query\sql to return all first time closed issues on certain date?

I looked at http://confluence.atlassian.com/display/JIRACOM/Example+SQL+queries+for+JIRA but no luck.

I do know the transition IDs that could move the ticket to Closed.

Oracle sql preferred. Thanks in advance.

3 answers

1 accepted

Thanks Renjith. I am using JIRA 3.13.5, so no JQuery for me.

I figured the SQL out my myself, probably not the most efficient, but does the job.

Issues closed yesterday but not previously closed before (a.k.a. closed first time yesterday)

select distinct(ji.pkey), 'Closed' as STATUS, trunc(sysdate-1) as CLOSE_DATE 
from jiraissue ji, changegroup cg, changeitem ci 
where ji.id = cg.issueid
and cg.id = ci.groupid
and ji.project = XXXXX --replace ji.project with your project ID
and cg.created between trunc(sysdate-1) and trunc(sysdate) 
and to_char(ci.newvalue) = '6' 
and to_char(ci.newstring) = 'Closed'                  
and ji.pkey not in ( select distinct(ji.pkey) --issues closed yesterday but was previously closed before
                  from jiraissue ji, changegroup cg, changeitem ci 
                  where ji.id = cg.issueid
                  and cg.id = ci.groupid
                  and cg.created < trunc(sysdate-1)  
                  and to_char(ci.newvalue) = '6' 
                  and to_char(ci.newstring) = 'Closed'
                  and ji.pkey in (select distinct(ji.pkey) --issues closed yesterday
                                    from jiraissue ji, changegroup cg, changeitem ci 
                                    where ji.id = cg.issueid
                                    and cg.id = ci.groupid
                                    and ji.project = XXXXX --replace ji.project with your project ID
                                    and cg.created between trunc(sysdate-1) and trunc(sysdate) 
                                    and to_char(ci.newvalue) = '6' 
                                    and to_char(ci.newstring) = 'Closed')                  
) order by ji.pkey;

1 votes
Renjith Pillai Community Champion May 07, 2012

Are you specific about SQL? If not this is directly possible using JQL with something like

status WAS "Closed" DURING ("01/01/2010","01/01/2011")

Try SQL for JIRA:

select * 
from issues
where JQL='status WAS "Closed" DURING ("01/01/2010","01/01/2011")'

no matters the vendor's legacy database (Oracle, MySQL...) it works for all of them (vendor independent).

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 ...

2,844 views 12 18
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