select a1,(a1/(select sum(a2) from test))*100 bili from test
解决方案 »
- 关于循环执行本地sql脚本
- 速度!请教大家一问题:设置Dbms_Output.put_line()输出长度大小的命令是什么?
- 求一条简单update语句
- 一个SQL语句的问题(之二:开帖加分)
- 误删了oracle10g的存储过程能恢复吗?
- 主机64位 win7 但virtualbox是32位win7
- oracle10g查询时提示非法的表名(invalid table name)
- 在 where 条件中, in (xxx,xxx,...) ,其中,xxx 可以有多少项,也就是in 可以有多少值?
- sqlplus下如何导出导入oracle数据库的数据?
- Oracle操作
- 怎么将数据插入到 oracle92中表分区中呢?
- 如何利用存储过程动态创建表?
from A, (select sum(col_2) as total from A) B
mysum number;
begin
select count(*) into mysum from A ;
select 字段一,字段二,字段二/mysum as 比例 from A;
end;
或者
select 字段一,字段二,字段二/(select sum(字段二) from a ) as 比例 from a
select A.col_1,A.col_2,concat(to_char(100*NVL(A.col_2,0)/B.total),'%')
from A, (select sum(col_2) as total from A) B
- ----------
a 10
b 30已用时间: 00: 00: 00.16
16:02:34 SQL> select a,b,ratio_to_report(sum(b)) over() from t1 group by a,b;A B RATIO_TO_REPORT(SUM(B))OVER()
- ---------- -----------------------------
a 10 .25
b 30 .75已用时间: 00: 00: 00.32
我这么用为何不可
declare a number ;
begin
select count(*) into a from 表名
select 字段一,字段二,字段2/a as 字段三 from 表名
end ;
/
错在哪儿了啊。