Reputation: 21
I want to get distinct records from the below query. I mean if we uncomment the commented lines.
Please help.
SELECT cs1.Nm AS CategoryType, cs2.Nm AS Category --, cs2.Nm AS sub_category
FROM Cat_Struct cs
INNER JOIN Cntrct_Cat cc
ON cc.Cat_Struct_Id = cs.Cat_Struct_Id
INNER JOIN Cat_Struct cs1
ON cs1.Cat_Cd = cs.Cat_Cd AND cs1.Mkt_Cd IS NOT NULL
INNER JOIN Cat_Struct cs2
ON cs2.Cat_Cd = cs.Cat_Cd AND cs2.Mkt_Cd IS NULL
--join Cat_Struct cs3
--on cs3.Cat_Cd = cs.Cat_Cd AND cs3.Mkt_Cd is null
--AND cs3.Sub_Cat_Cd is not null
WHERE
cs.LOB_Cd ='P'
AND cc.Cntrct_Vers_Id = 781439637
AND cs2.Nm = 'adult books'
Upvotes: 2
Views: 67
Reputation: 93
Use the Keyword Distinct in select statement.
Yow will get the records which are not repeated.
Thanks
Upvotes: 1