Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem in generating Associations

Status
Not open for further replies.

azwaan

Programmer
Jan 11, 2002
42
i have a transaction table that which looks somewhat like this, only a lot more data

TranID ITEM
1 soap
1 coke
1 bag
2 coke
2 apple
3 soap
2 apple

i have the following statement to show association rules

SELECT b1.item, b2.item AS item2, count(*) as support
FROM transactions AS b1, transactions AS b2
WHERE b1.tranid=b2.tranid and b1.item < >b2.item
GROUP BY b1.item, b2.item
HAVING count(*) > = 3
ORDER by b1.item, b2.item
OPTION (hash group)

the results i get is somwhat like this,

Item Item2 Support
row1 apple coke 2
row2 coke apple 2
row3 coke soap 3
row4 soap coke 3

as shown, there rows 1 & 2 contain the same data. as does rows 3 & 4.

can someone suggest how i can modify the statement to avoid duplicates ? or an alternative way of doing this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top