im trying to display a result based on 2 multi-conditional columns. I have 3 columns,One being a client, one of them is Product and one of them is Class. There are multiple products that each have multiple classes. I only want to display the results of specific classes of different products. Eg : Product X has a class of 1,2,3 I only want to see the results of Product X of classes 1 & 2. Product Y has a class of 1,2,3 but i only want to see results of Product Y for 1&3. Im new to SQL,is this something that i would need to use multiple case statements for or will that not work because that only works the result of a column? Or multiple select statements? Thanks in advance for any help! ๐
Client Product Class
Jeff X 1
Bill X 2
Sam X 3
Wendy Y 1
Jane Y 1
Tom Y 2
Dave Y 3
------------Result----------
Jeff X 1
Bill X 2
Wendy Y 1
Jane Y 1
Dave Y 3
โ
Advertisement
Answer
You should be able to get the results you are looking for by using a where clause with an OR statement.
WHERE (product=โxโ AND class IN (1,2)) OR (product=โyโ AND class IN (1,3))
โ