Since a while i have to find a way of comparing "Sets" (multiple int Values) and so to find equal sets. There simply 3 tables
ValueList with: ID int
ValueListHasValue: ID int, ValueListID int, ValueID int
Value: ID int, Description varchar(max)
The sets are defined in the ValueList has ValueTable. Any combination and order is possible as there is also no restriction on the amount of Values in a ValueList. My first approach was to use CTE and Checksum_AGG
Expand|Select|Wrap|Line Numbers
- ;WITH CTE1(ValueListID, chksum) AS
- (
- Select ValueListId, CHECKSUM_AGG(CHECKSUM(ValueListHasValue.ValueId)) from ValueListHasValue
- Group By ValueListId
- ),
- CTE2(ValueListID, chksum) AS
- (
- Select varValueList.ValueListId, CHECKSUM_AGG(CHECKSUM(varValueList.ValueId)) from @VarValueList varValueList
- Group By ValueListId
- )
- Select CTE1.ValueListId from CTE1,CTE2 where CTE2.chksum = CTE1.chksum
Does anybody has a buzzwrd for me to start googling or perhaps a solution for this?