How to query the Jira database for issue type statistics per project

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible


The SQL queries in this article are only provided on best-effort basis and are not supported by Atlassian.

Summary

Admins may want to pull statistics of how many issue types there are per project in Jira. 

Solution

Run the SQL query: 

(warning) This query was written for Postgres and may have to be updated to work on another database:

SELECT p.pkey, it.pname, COUNT(i.id) FROM jiraissue i 
INNER JOIN project p ON i.project = p.id 
INNER JOIN issuetype it ON it.id = i.issuetype 
GROUP BY (p.id, it.id) ORDER BY p.pkey, count DESC;

Here's a sample output of the results from a test system: 

    pkey    |      pname      | count
------------+-----------------+-------
 ITSRVDSK   | Service Request |    35
 ITSRVDSK   | Incident        |     4
 ITSRVDSK   | Task            |     3
 ITSRVDSK   | Change          |     2
 ITSRVDSK   | Problem         |     1
 PMGMT      | Task            |     6
 SCRUMMY    | Story           |    36
 SCRUMMY    | Sub-task        |    10
 SCRUMMY    | Bug             |     4
 SCRUMMY    | Epic            |     2
 SCRUMMY    | Task            |     1
 SCRUMMY    | Initiative      |     1
 SCRUMMYTWO | Story           |    16
 SCRUMMYTWO | Bug             |     4
 SCRUMMYTWO | Sub-task        |     3
 SD         | Service Request |    32
 SD         | Incident        |     5
 SD         | Change          |     2
 SD         | Problem         |     1
(19 rows)



Last modified on Oct 31, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.