Querying your data

Now that you have your data fetched (if not please ensure to follow the Installation guide first) you can start querying your data.

SQL for Jira Cloud uses the following data model, also known as ER (entity relationship): SQL for Jira Cloud data model

You can use standard SQL queries to query the data. For example, to fetch all the issues just run:

SELECT * from issues

If you’d like to select only issues from project with key MYPROJ, just join projects table and filter by project key:

SELECT issues.* FROM issues
INNER JOIN projects ON issues.project_id = projects.id
WHERE projects.key = "MYPROJ"

To select specific properties of the issues, update the SELECT clause:

SELECT issues.key, issues.summary, issues.status FROM issues
INNER JOIN projects ON issues.project_id = projects.id
WHERE projects.key = "GTMS"
Selecting specific Jira Issue properties via SQL query

You can also use SQL functions to aggregate data. For example, to count the number of issues in each status:

SELECT issues.status, COUNT(*) as number_of_issues FROM issues
INNER JOIN projects ON issues.project_id = projects.id
WHERE projects.key = "GTMS"
GROUP BY issues.status
GROUP BY Jira data using SQL

So pretty much anything that SQL can offer can be used to query your Jira data.

And if you need some help crafting queries, check out the next article about how AI requests work: AI requests