日期:2014-05-17  浏览次数:20937 次

oracle 查询问题
create table test(
  rq varchar2(10),
  shengfu varchar2(2)
);

insert into test values ('2012-1-1','胜');
insert into test values ('2012-1-2','负');

查询显示为:
  胜 负
2012-1-1 1 1


求解!

------解决方案--------------------
可以告诉我你这条结果怎么来的吗?
负明明是2012-1-2号的,怎么会跑到2012-1-1号呢?
------解决方案--------------------
SQL code

select rq,
       sum(decode(shengfu,'胜',1,0)) 胜,
       sum(decode(shengfu,'负',1,0)) 负
from test
group by rq

------解决方案--------------------
select rq,sum(decode(shengfu,'胜',1,0)) 胜,sum(decode(shengfu,'负',1,0)) 负 from test
group by rq