Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

finding all possible grouping combinations

635179Apr 30 2010 — edited Apr 30 2010
Hi

I have a table of colour names, and need to retrieve every conceivable combination of colour groups. As an example, suppose i have the following table:-
WITH colours AS (SELECT 1 id, 'red' colour FROM DUAL
               UNION ALL
               SELECT 2 id, 'blue' colour FROM DUAL
               UNION ALL
               SELECT 3 id, 'green' colour FROM DUAL)
SELECT *
  FROM colours
I would want to retrieve the following results:-
group  id
1       1
2       2
3       3
4       1
4       2
5       1
5       3
6       2
6       3
7       1
7       2
7       3
Could somebody please enlighten me on how i would extract this resultset?

Edited by: tri_harder on Apr 30, 2010 1:42 PM spelling update
This post has been answered by 189821 on Apr 30 2010
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 28 2010
Added on Apr 30 2010
12 comments
4,980 views