I have to find out the combinations of three columns of a table by using PL / SQL in DL. For intentions, see the following table table (stand for A, B, C column name and stand for v1, v2, v3 ... column values):
- + - ---- + ----- + ----- + - - | A. B C. - - + ----- + ----- + ----- + - - | V1 | V2 | V3 | - - + ----- + ----- + ----- + - - | V4 | V5 | V6 | - - + ----- + ----- + ----- + - - | : | : | : - ::: My module should produce each combination of these three columns, A, B, C:
v1 v2 v3 v1 v2 V6 v1 v5 v3 v1 v5 v6 ........ v4 v2 v3 v4 v2 v4 v5 v3 v4 v5 v6 ........ ::::: Even more so
Can anyone suggest the most efficient algorithms for this process? Thank you.
All combinations in a cartesian will be produced which you are seeing. As all three columns are in the same table, you need to temporarily split the table into three pieces:
SELECT * FROM (select from my apple), (SELECT b FROM mytable), (SELECT C mytable);
No comments:
Post a Comment