Tuesday, July 1, 2014

Identify the itemids

If you want just itemid listed use this



SELECT itemid
FROM xyz
GROUP BY itemid
HAVING SUM(CASE WHEN prodid= 5 THEN 1 ELSE 0 END) = 0



if you want details also use this



SELECT *
FROM xyz t
WHERE NOT EXISTS (SELECT 1
FROM xyz
WHERE itemid = t.itemid
AND prodid = 5
)





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment