I want to intersect between values of one column based on another column. I mean if I have three different values in Id column, I want the values of LineGroupBy column to be assumed as one group(Id=1) and intersected with other groups(Id=5 or 8) Here is the table:
LineGroupBy Id
ItemTypeId 8
ItemId 1
BankAccountId 5
ItemTypeId 1
VATId 1
InOut 5
FundTypeId 5
CurrencyId 5
VATPer 1
ItemId 8
the result of query should be NULL. As you can see the LineGroupBy values of Id=1 is (ItemId,ItemTypeId,VATId,VATPer), Id=5 is (InOut,FundTypeId,CurrencyId) and Id=8 is (ItemTypeId,ItemId).
So Id=1 and Id=8 has an intersect of (ItemTypeId,ItemId) but overall there is no intersect between all Ids.
I tried this but it is static(address exact Ids) and I want a query without addressing Ids.
SELECT *
FROM #temp T
WHERE T.Id=1
INTERSECT
SELECT *
FROM #temp T
WHERE T.Id=5
INTERSECT
SELECT *
FROM #temp T
WHERE T.Id=8
I find this code to state the overlaps but this code does not say what is the intersect of all groups.
An extra code to find a route of all Ids could work.