I am trying to get the linked test cases associated to a defect. The Problem arises when i run the query, i am getting duplicate values even when there is a "DISTINCT" clause to the query.
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*/
I am not good at SQL, So i would appreciate any kind of suggestion that i recieve.
System : HP ALM Database : SQL
Let me know if you need any more details.
EDITED : Hope this helps, If you can see, i have only two test cases linked to defect 95, but the query returns 2 result for each. So if there is 4 test cases linked to a defect, there will be around 16 Link_Id Defect_ID Defect_Status TestCase_status TestCase_Name 768 95 Awaiting Retest Failed TC_01_XXXXXXX 768 95 Awaiting Retest No Run TC02_XXXXXXXX 787 95 Awaiting Retest Failed TC_01_XXXXXXX 787 95 Awaiting Retest No Run TC02_XXXXXXXX