I am new to SSMS and I have a feeling this should be easy but I have no clue on how to do it. For the sake of simplicity, I renamed my tables.
SKU Reason
s1 r1
s1 r2
s1 r3
s2 r1
s2 r3
s3 r5
s3 r1
s3 r4
To give a context, SKU 's1' is excluded because of three reasons: r1, r2, r3. s2 is excluded because of 2 reasons r1 and r3. s3 is excluded because of 3 reasons r5,r1, and r4.
I can filter the application based on SKU or Reason or both. If I filter based on reason r1, it should return me all SKUs that are excluded because of r1 i.e s1, s2, s3 in the above example. If I filter based on reason r1 and SKU s1, its currently returning me s1 and r1 in the result which is what I wanted.
Now, the requirement has changed. If I filter based on reason r1 for SKU s1, it should not only return me s1 and r1 but also other reasons because of which sku s1 is excluded. i.e it should return s1 r1, s1 r2, s1 r3. However, if I filter by reason r5 for SKU s1, it should return nothing as SKU s1 is not excluded by reason r5.
Current Implementation:
Filter Criteria: Sku s1 and Reason R1
SKU Reason
s1 r1
I want to change it to:
Filter Criteria: Sku s1 and Reason R1
SKU Reason
s1 r1
s1 r2
s1 r3