好恐怖啊!改了半天!! 8i以上可以!8i的话没试!!!
[php]SQL> select * from t1;
A B
C
---------- -------------------- --------------------
1 非GMP
1,10
2 GMP
2,10
10 单独定价
2,10
0 其他
2,10
SQL> select rn1||','||rn2 b,c
2from (
3select max(decode(rn,1,b,null)) rn1,max(decode(rn,2,b,null)) rn2,c
4from (
5select b,c,row_number() over(partition by c order by b) rn
6from (
7select b,c1||','||c2 c
8from
9(select substr(c,1,1) c1,substr(c,3) c2 from (select distinct c from t1) ) t1,
10(select a,b from t1) t2
11where t2.a =t1.c1 or t2.a=t1.c2))
12group by c);
B
C
-------------------- --------------------
单独定价,非GMP 1,10
GMP,单独定价 2,10[/php]
|