How to query the Jira database for issue type statistics per project
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:
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)