Created
March 19, 2020 19:19
-
-
Save dorkness-io/715e759f36708369abaa8242349fbc50 to your computer and use it in GitHub Desktop.
A brief example that retrieves a count of comments per project. We retrieve the counts for each each issue in a sub-select, and then aggregate by project and sum at the top level. Demonstrates the "count" and "sum" aggregate functions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
ss.pname | |
,sum(ss.comment_count) as sum_comments | |
from ( | |
select | |
p.pname | |
,p.pkey || '-' || ji.issuenum AS issue_key | |
,count(distinct ja.id) as comment_count | |
from jiraissue ji | |
join project p | |
on ji.project = p.id | |
join jiraaction ja | |
on ji.id = ja.issueid | |
and actiontype = 'comment' | |
group by 1,2 | |
) ss | |
group by 1 | |
order by sum_comments desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment