有6个值,每个值的取值范围都是(0,1,2)
写个语句把它们不同排列的情况列出来就像这样0 1  2  2  1  0
2 0  2  0  1  0
。。
。。
1 0  0  2  1  1
2 2  2  2  2  2

解决方案 »

  1.   

    你可以按下面这种方法做下去。SQL> select distinct a1.k,a2.k
      2  from (
      3  select 1 as k from dual
      4  union select 2 from dual
      5  union select 3 from dual
      6  ) a1,
      7  (
      8  select 1 as k from dual
      9  union select 2 from dual
     10  union select 3 from dual
     11  ) a2;         K          K
    ---------- ----------
             1          1
             1          2
             1          3
             2          1
             2          2
             2          3
             3          1
             3          2
             3          39 rows selected.SQL>
      

  2.   

    select *
    from(select rownum-1 a from all_objects where rownum<4)a,
      (select rownum-1 b from all_objects where rownum<4)b,
      (select rownum-1 c from all_objects where rownum<4)c,
      (select rownum-1 d from all_objects where rownum<4)d,
      (select rownum-1 e from all_objects where rownum<4)e,
      (select rownum-1 f from all_objects where rownum<4)f