I'm not sure my title above makes sense, so I'll try to clarify. I'm using SQL Server.
I have a table called Orders that looks like this (truncated):
Order_Number | SKU
1 | abc
1 | def
1 | ghi
2 | abc
2 | ghi
3 | def
4 | abc
4 | def
4 | ghi
5 | abc
I need to find all Order Numbers that include SKUs abc and ghi. So if I ran the query on the above table, it would return:
Order_Number
1
2
4
If the Order Number only includes abc
or ghi
, not both, I don't want to return the Order Number. If it includes extra SKUs, such as def
, that is OK, I still want to return the record. I don't need to see all the SKUs in the output, just the Order Number. Does that make sense?
Thanks in advance!