select * from
(select sum(fee) from table where flag='R1') a,
(select sum(fee) from table where flag='R2') b,
(select sum(fee) from table where flag='R3') c,
(select sum(fee) from table where flag='R4') d,
(select sum(fee) from table where flag='R5') e,
(select sum(fee) from table where flag='R6') f
(select sum(fee) from table where flag='R1') a,
(select sum(fee) from table where flag='R2') b,
(select sum(fee) from table where flag='R3') c,
(select sum(fee) from table where flag='R4') d,
(select sum(fee) from table where flag='R5') e,
(select sum(fee) from table where flag='R6') f
解决方案 »
- 該如何顯示A資料表與B資料表相同的資料
- sql 变量查询问题
- 如何查看数据库是专有服务器模式,还是共享服务器模式?
- 高手来帮帮忙 如何在PACKAGE BODY 中引用存储过程!
- 我想学Oracle,刚安装完Oracle10G出现登陆出现如下错误请高手指教!
- Oracle10g创建表奇怪的问题,总是多创建一个BIN$DKb打头的空表
- 在oracle 9i安装中遇到的问题,关于JDK home directory ?请帮忙解答,100分酬谢!!!
- 有个insert问题
- oracle存储过程问题!
- 数据库可不可以小一点
- 青帮忙解释一下一段关于显示VARRAY中数据的PL/SQL语句?
- 关于定期自动执行sql块的问题,再问。(在线,立即结帐)
Result varchar2(100);
cursor t_cursor(v_flag varchar2) is
select sum(fee) fee from table
where flag=v_flag;
v_count Number;
begin
v_count:=0;
Result:='';
for v_sor in t_cursor(p_flag) loop
if v_count=0 then
Result:=v_sor.fee;
v_count:=v_count+1;
else
Result:=Result||','||v_sor.fee;
end if;
end loop;
return(Result);
end get_sum;
/select get_sum(flag) from table group by flag;
sum(decode(flag,'R2',fee,0)) R2,
sum(decode(flag,'R3',fee,0)) R3,
sum(decode(flag,'R4',fee,0)) R4,
sum(decode(flag,'R5',fee,0)) R5,
sum(decode(flag,'R6',fee,0)) R6
from table
(select sum(fee) sum1 from table where flag='R1') a,
(select sum(fee) sum2 from table where flag='R2') b,
(select sum(fee) sum3 from table where flag='R3') c,
(select sum(fee) sum4 from table where flag='R4') d,
(select sum(fee) sum5 from table where flag='R5') e,
(select sum(fee) sum6 from table where flag='R6') f;其实如果不按你要求得格式还可以:
SELECT FLAG,SUM(FEE)
FROM table
GROUP BY FLAG;