Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SQL Query to mimic the results in SprintReport - Solved

Just wanted to share some query on what i've been struggling for a while now, basically i needed to have a query (sql) where i could see information similar to what is shown in the Sprint report, and show some graphics on what was committed at the beginning of each sprint and what was part of a scope change after the sprint was started.

it toke me a while to come up with a solution and finally i found out a way, hope some one else find this use-full in your implementation.

SELECT AS issueid,
concat(p.pkey, '-', ji.issuenum)::character varying AS IssueKey,
s."ID" AS sprintid,
s."NAME" as SprintName,
to_timestamp((s."START_DATE" / 1000)::double precision) AS SprintStart,
to_timestamp((s."END_DATE" / 1000)::double precision) AS SprintEnd,
to_timestamp((s."COMPLETE_DATE" / 1000)::double precision) AS SprintCompleted,
p.pname as ProjectName,
-- This Here is the tricky part, we have to evaluate two sources of info, ChangeGroup and CustomFieldValue
-- If ChangeGroup returns null (probably bc the issue was created directly into the sprint)
-- Then we have to Search in the customFieldValue.created value (sprint fieldId is 10001 in my implementation)
FROM Changegroup cg -- Searching the changegroup/change itme tables
INNER JOIN ChangeItem ci on ci.groupid = AND ci.field = 'Sprint'
WHERE cg.issueid =
AND ci.newvalue ~ s."ID"::text
AND NOT COALESCE(ci.oldvalue,'') ~ s."ID"::text
(SELECT TO_TIMESTAMP(cfv.updated/1000) --if null was returned from the previous query then we just search the
-- value in the customfieldvalue.updated
FROM customfieldvalue cfv
WHERE cfv.issue = AND cfv.customfield=10001::numeric
AND cfv.stringvalue::bigint = s."ID"
LIMIT 1)) AS AddedToSprintDate
FROM jiraissue ji
JOIN project p ON ji.project =
JOIN nodeassociation na ON = na.source_node_id AND na.sink_node_entity::text = 'ProjectCategory'::text
JOIN customfieldvalue cfv ON cfv.issue =
JOIN "AO_60DB71_SPRINT" s ON cfv.customfield = 10001::numeric AND s."ID" = cfv.stringvalue::bigint
JOIN issuetype it ON ji.issuetype::text =
WHERE it.pname::text = 'Story'::text
AND s."ID" = 3169 --Finally filter by the sprintid you want the report from

1 comment

this is awesome !!! it worked for me and I exported the data to chamostudio.


well done


Log in or Sign up to comment

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you