我有以下场景来实现使用SQL语句, 我有一个问题分配给Triage,GX,GY组:
小组分诊 - > GX组
组GX - >组Triage
小组分诊 - > GY小组
我想第一次将我的问题分配给Triage组并忽略其余部分,我试图这样做但总是结果不好(当分配给Triage组的问题时检索所有行)
SQL语句:
select g.created ,ji.pkey as issueName
from changegroup g
join changeitem ci on (ci.groupid = g.id)
join jiraissue ji on (ji.id = g.issueid)
join project p on (p.id = ji.project)
join priority pr on (pr.id = ji.priority)
where ci.field = 'Group'
and ci.oldString = 'Triage'
and p.pname = 'Test'
and pr.pname='P3'
and ji.created between '2011-08-11 14:01:00' and '2011-08-12 14:11:00'
语句的结果(如您所见,问题200被分配给组Triage 2次,因此请求检索2行):
表更改组具有以下结构:
表changeitem具有以下结构:
答案 0 :(得分:0)
试试这个。但它可能是非常慢的查询
select g.created, ji.pkey as issueName
from changegroup g
join jiraissue ji on (ji.id = g.issueid)
where (g.created, issueName) in (
select min(g.created) ,ji.pkey as issueName
from changegroup g
join changeitem ci on (ci.groupid = g.id)
join jiraissue ji on (ji.id = g.issueid)
join project p on (p.id = ji.project)
join priority pr on (pr.id = ji.priority)
where ci.field = 'Group'
and ci.oldString = 'Triage'
and p.pname = 'Test'
and pr.pname='P3'
and ji.created between '2011-08-11 14:01:00' and '2011-08-12 14:11:00'
group by issueName
)