The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Total Spent Time On Sql Query for Parent Task

PRABHURAM K R
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 23, 2019
Hi, I want to know how to get the Parent Task Jira's Total Time Spent which is divided By Sub Task on Worklog's.. Any One Please help With Table name or Function That are Being used to get the Time Spent for Parent Task.. Please I need SQL Query for that..

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
PRABHURAM K R
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 23, 2019

But JIRA version is 7.4 which doesnt has a Table JIRAISSUE,Subtask Tables... Could you please help me with this..

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 23, 2019

There is only the jiraissue table.

But since I'm connecting jiraissue to another instance of jiraissue, I used an alias for the second table so that I know that this is the one I will use for subtask-level information.

For example, very simplified, without any linkage, here is selects from 2 tables (don't run this on a real db, especially if you have lots of issues).

SELECT
parentIssue.*,
subtaks.*
FROM
jiraissue parentIssue,
jiraissue subtask

 Here is what my earlier query looks like in a graphical query builder tool:

c235ec83-c64d-473c-a9df-17d5198f4e59.png

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 23, 2019

Each jiraissue record in the DB has its own "timespent" value. This will not necessarily match the sum of all associated jiraworklog entries for a given issue.

Linking between parent issue and subtask is done via the issuelink table where linktype = 10000 (or consult issuelinktype to make sure you get the correct id)

If you want to sum all the timespent from subtasks, you can try a SQL query like this:

SELECT
project.pkey,
jiraissue.issuenum,
Sum(subtasks.TIMESPENT) AS Sum_TIMESPENT
FROM
jiraissue
INNER JOIN project ON project.ID = jiraissue.PROJECT
LEFT JOIN issuelink ON issuelink.SOURCE = jiraissue.ID
LEFT JOIN jiraissue subtasks ON subtasks.ID = issuelink.DESTINATION
WHERE
project.pkey = 'JSP' AND
issuelink.LINKTYPE = 10000
GROUP BY
project.pkey,
jiraissue.issuenum,
issuelink.LINKTYPE