SQL在Query中返回重复值

时间:2017-11-09 13:24:35

标签: sql hp-quality-center

我正在尝试将链接的测试用例与缺陷相关联。当我运行查询时出现问题,即使查询中存在“DISTINCT”子句,我也会获得重复值。

Select Distinct  LINK.LN_ENTITY_ID as "Link_Id",
Bg_Bug_ID as "Defect_ID",
Bg_Status as "Defect_Status",
TC_STATUS as "TestCase_status",
TS_NAME as "TestCase_Name"

from (BUG LEFT JOIN LINK ON BG_BUG_ID = LN_BUG_ID )
LEFT JOIN V_LINK_TESTCYCL on LINK.LN_BUG_ID = V_LINK_TESTCYCL.LN_BUG_ID
LEFT JOIN CYCLE ON LINK.LN_ENTITY_ID = CY_CYCLE_ID
LEFT JOIN TESTCYCL on V_LINK_TESTCYCL.LN_TESTCYCL_ID = TC_TESTCYCL_ID
left join test on tc_test_id = ts_test_id

Where
--NOT IN ('Closed','Defect Resolved','Rejected')
BG_STATUS NOT IN ('Closed','Defect Resolved','Rejected')
--BG_STATUS = 'Awaiting Retest'
AND LINK.LN_ENTITY_TYPE = 'TESTCYCL'
AND TC_STATUS NOT IN ('Passed')
ORDER BY LINK.LN_ENTITY_ID
--Group by BG_BUG_ID,LINK.LN_LINK_ID LINK.LN_ENTITY_ID /*Associated.LinkedEntity ID*/

我不擅长SQL,所以我很感激我收到的任何建议。

系统:HP ALM 数据库:SQL

如果您需要更多详细信息,请与我们联系。

编辑:希望这会有所帮助,如果你能看到,我只有两个测试用例链接到缺陷95,但查询返回每个测试结果2。因此,如果有4个测试用例与缺陷相关联,则会有大约16个 Link_Id Defect_ID Defect_Status TestCase_status TestCase_Name 768 95等待重新测试失败TC_01_XXXXXXX 768 95等待重新测试否运行TC02_XXXXXXXX 787 95等待重新测试失败TC_01_XXXXXXX 787 95等待重新测试否运行TC02_XXXXXXXX

0 个答案:

没有答案