SQL Joins - Identify the missing lines

Viewed 76

I have a requirement to find all the rows with a specific tag,that does not have a corresponding line with a different tag.

My Table structure is as follow :

Year, Week, Brand, Country, LoactionCode, ProductCategory, VolumeType, Division, Activity, Tag, Qty

Some data samples :

 2016,1,Dell, USA, 100, Computers, Accessories, Retail, Pricing, 'CF',800
 2016,1,Dell, USA, 100, Computers, Accessories, Retail, Tagging, 'CF',1500
 2016,1,Dell, USA, 100, Computers, Accessories, Retail, Pricing, 'OF',1000
 2016,1,Dell, USA, 100, Computers, Accessories, Retail, Tagging, 'OF',1200
 2016,1,Dell, USA, 100, Computers, Accessories, Retail, Bagging, 'OF',1200

I wanted to get the rows which has a tag of 'OF' but do not have corresponding rows with tag 'CF' matching on all the fields "Year, Week, Brand, Country, LoactionCode, ProductCategory, VolumeType, Division, Activity"

Please could some one help me with this ?

2 Answers
Related