日期:2014-05-16 浏览次数:20647 次
SELECT T1.ID,
T8.cname,T9.vname
FROM issue T1
left join nodeassociation T7 on T1.ID=T7.SOURCE_NODE_ID
left join component T8 on T7.SINK_NODE_ID =T8.ID
left join projectversion T9 on T7.SINK_NODE_ID =T9.ID
WHERE T1.ID=62360
ID cname vname
62360 文件服务器 NULL
62360 NULL AE2.1_SP2_20140315
SELECT T1.ID,
max(T8.cname) as cname,max(T9.vname) as vname
FROM issue T1
left join nodeassociation T7 on T1.ID=T7.SOURCE_NODE_ID
left join component T8 on T7.SINK_NODE_ID =T8.ID
left join projectversion T9 on T7.SINK_NODE_ID =T9.ID
WHERE T1.ID=62360
group by
t1.id
SELECT T1.ID,
min(T8.cname) cname,
min(T9.vname) vname
FROM issue T1
left join nodeassociation T7 on T1.ID=T7.SOURCE_NODE_ID
left join component T8 on T7.SINK_NODE_ID =T8.ID
left join projectversion T9 on T7.SINK_NODE_ID =T9.ID
WHERE T1.ID=62360
group by t1.id
SELECT T1.ID,
T8.cname,
T9.vname
FROM issue T1
OUTER APPLY (SELECT TOP 1 c.cname FROM nodeassociation n INNER JOIN component c ON n.SINK_NODE_ID =c.ID WHERE c.SOURCE_NODE_ID = T1.ID AND n.SINK_NODE_ENTITY='Component') T8
OUTER APPLY (SELECT TOP 1 v.vname FROM nodeassociation n INNER JOIN projectversion v ON n.SINK_NODE_ID =v.ID WHERE c.SOURCE_NODE_ID = T1.ID AND n.SINK_NODE_ENTITY='Version' ) T9
WHERE T1.ID=62360