Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Finding all possible unique combinations of values

$
0
0

Hello,
I am looking for thoughts on how to find all possible combinations of values, for example:

My table includes:
Code:

CREATE TABLE temp1 (item varchar(50), ORDER int);

INSERT INTO temp1 (item, order) VALUES ('apple',1);
INSERT INTO temp1 (item, order) VALUES ('pear',2);
INSERT INTO temp1 (item, order) VALUES ('blueberry',3);



I need the output to be like this:

apple
pear
blueberry
apple, pear
apple, blueberry
pear, blueberry
apple, pear, blueberry

I don't need the reverse of each. For example, I need only 'apple, pear'... I don't need 'pear, apple'.


Would love some guidance!
Thanks in advance!

Viewing all articles
Browse latest Browse all 13329

Trending Articles