发现decode行转列之后 , 小数, 负数都会自动抹去 , 需要to_char加工一下 , 并没有找到相关文献解释为什么抹去 SQL> create table test0724 (name varchar(20),month number(2),num NUMBER(6,2));
insert into test0724 values('a',01,1.1);
insert into test0724 values('a',01,2.2);
insert into test0724 values('b',02,1.1);
insert into test0724 values('b',02,2.2);
insert into test0724 values('a',02,1.1);
insert into test0724 values('a',02,2.2); insert into test0724 values('b',01,1.1);
insert into test0724 values('b',01,2.2); insert into test0724 values('a',03,-1.1);
insert into test0724 values('a',03,-2.2); insert into test0724 values('b',03,-1.1);
insert into test0724 values('b',03,-2.2); select name,min(jan),min(feb),min(mar) from (
select name,decode(month,01,to_char(num,'S99999.99'),0) jan,decode(month,02,to_char(num,'S99999.99'),0) feb,decode(month,03,to_char(num,'S99999.99'),0) mar from test0724 ) group by name;
|