JIRA mysql query to count issues per assigned group

Todor Kostadinov July 13, 2017

Hello,

I need to export information about all issues in all groups.

Jira "Issue statistics" gadget in the dashboard provides the exact information I need, but I'm not able to export to xls.

I searched thru jira mysql db, but was not able to identify the tables that I need.

The information I need is like this:

Groupname               Total issues

Groupname_1             256

Groupname_2             298

Groupname_3             1562

........

 

Can anyone help?

5 answers

0 votes
Todor Kostadinov July 14, 2017

Well, may be I'm missing something, but it is not working for me.

I changed the cfname to the name of my customfield:

SELECT b.customvalue as 'Option', COUNT(a.ID) as 'Number'
FROM customfieldvalue a JOIN customfieldoption b ON a.stringvalue = b.ID
WHERE a.CUSTOMFIELD = (select ID from customfield WHERE cfname = 'Assigned Group') GROUP BY a.STRINGVALUE;

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2017

Gods I hate SQL shorthand, makes it really hard to read.

I tihnk you're going in the right direction, but I think the problem is that the custom field is a group-picker, not an option list, so you should be reading groups instead of options. 

I should check that, but I don't have a JIRA to hand at the moment (yay, trains with intermittent wifi)

Todor Kostadinov July 16, 2017

The last one is working.

Thank you!

0 votes
Todor Kostadinov July 14, 2017

I also forgot to mention that we are using JIRA 6.2.

I presume Stefan's select is for more recent JIRA version.

 

Regards,

Todor Kostadinov

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2017

No, he's done two things:

1.  Made it look up the field name, so you don't have to work out the ID of the custom field manually.

2.  Added SQL shorthand, which makes it easier to type and a lot harder to read.

Both your SQL and his work perfectly for most versions of JIRA - I'd actually say version 4.0 through to 7.4, as I don't remember the customfield tables changing since 4.0

Stefan Arnold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2017

I have written it for JIRA 7.3 but now tried it in JIRA 6.1 too.

Working perfectly. And will work for 6.2 too.

Make sure you enter your customfieldname to cfname.

 

Stefan Arnold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2017

Sorry Todor, Nic is right.
Didnt recognized you mentioned that its a grouppickerfield.
They really have no options in customfieldoptions table.

So i did same as you and joined only the customfieldtable to be able too simply enter the customfield name.

SELECT customfieldvalue.STRINGVALUE as 'Group', COUNT(customfieldvalue.ID) as 'Number' FROM customfieldvalue JOIN customfield ON customfieldvalue.CUSTOMFIELD = customfield.ID WHERE customfield.cfname = 'Jira-Groups' GROUP BY customfieldvalue.STRINGVALUE

This time without shorthand^^

0 votes
Stefan Arnold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2017
SELECT b.customvalue as 'Option', COUNT(a.ID) as 'Number' FROM customfieldvalue a JOIN customfieldoption b ON a.stringvalue = b.ID WHERE a.CUSTOMFIELD = (select ID from customfield WHERE cfname = 'YOURCUSTOMFIELDNAME') GROUP BY a.STRINGVALUE;

This is a little bit more clean. 

0 votes
Todor Kostadinov July 13, 2017

Well,

I just found the table I need:

 

SELECT STRINGVALUE, COUNT(*) FROM customfieldvalue
WHERE CUSTOMFIELD = 'Assigned group custom field number'
GROUP BY STRINGVALUE;

0 votes
Todor Kostadinov July 13, 2017

Sorry,

forgot to mention that "Assigned group" is custom field - Group Picker (single group).

Suggest an answer

Log in or Sign up to answer