I have a request that return bad result and I can’t fix it,the calculation is wrong ,
My query:
select TIMEDIFF(a.CREATED,b.CREATED)
from
(
select changegroup.CREATED
from changegroup,changeitem,project,jiraissue
where changegroup.id=changeitem.groupid
and field='Group'
and oldString='Triage'
and jiraissue.id=changegroup.issueid
and project.id=jiraissue.project
and project.pname='Test'
and jiraissue.CREATED between '2011-08-11 14:01:00' and '2011-08-11 14:11:00'
) a,
(
select jiraissue.CREATED
from jiraissue ,changegroup,project
where jiraissue.id=changegroup.issueid
and project.id=jiraissue.project
and project.pname='Test'
and jiraissue.CREATED between '2011-08-11 14:01:00' and '2011-08-11 14:11:00'
) b;
the result of the subquery1:

the result of the subquery2:

The Result of the query:

The Result wanted :

The relation between tables

thank you
First of all I’d rewrite your query as follows, just to clearly show the connections between the tables in the query:
I think you are missing the link between two subqueries. It really depends on what you are trying to accomplish. If I understood you well, and you just want to calculate the time difference between jira issue creation date and the creation date the issue belongs to, following query should do the trick (more less, based on your query):
Please specify in detail what are you trying to accomplish and maybe I could help more.