如题。
我要实现的功能的代码(SQL Server 2000下)是:
declare @total NUMERIC(16,9)
set @total=(select sum(DBLUNVOUCHERDEBIT) from accountdaily)select sum(DBLUNVOUCHERDEBIT)/@total from accountdaily group by LNGACCOUNTID在Oracle中该如何实现?
我要实现的功能的代码(SQL Server 2000下)是:
declare @total NUMERIC(16,9)
set @total=(select sum(DBLUNVOUCHERDEBIT) from accountdaily)select sum(DBLUNVOUCHERDEBIT)/@total from accountdaily group by LNGACCOUNTID在Oracle中该如何实现?
解决方案 »
- 求助:如何pl/sql遍历record里面字段(不用字段名)
- js只可已输入中文验证,本地测试可以,手机浏览器无法识别,不能使用?求解决方案
- 查询丢失数据
- 菜鸟求助 如何把一个日期转换成当天的0点0分0秒?
- cluster表中的size参数
- Oracle procedure
- 是否可以同一个job调用多个过程
- 一个问题?
- vb与oracle 8i的日期问题?????????????????????????
- 安装oracle11g的时候显示Oracle Net Configuration Assistant 失败,手动配置netca也失败,急
- 求一段代码将ORACLE数据库中所有表的结构用文本导出.(表较多)
- oracle中有没有sql中类似的checknum函数啊?
total number(16,9);
begin
select sum(DBLUNVOUCHERDEBIT) into total from accountdaily;
--余者同此处理。
end;
create or replace procedure ss(curs out REFCURSOR) is
total NUMERIC(16,9);
begin
total=(select sum(DBLUNVOUCHERDEBIT) from accountdaily);
open curs for select sum(DBLUNVOUCHERDEBIT)/@total from accountdaily group by LNGACCOUNTID;
end ss;都可以用
create or replace package package_cur is
type ref_cursor is ref cursor;
end package_cur;create or replace procedure proselect(srefcursor out package_cur.ref_cursor) is
total NUMERIC(16,9);
begin
total=(select sum(DBLUNVOUCHERDEBIT) from accountdaily);
open curs for select sum(DBLUNVOUCHERDEBIT)/@total from accountdaily group by LNGACCOUNTID;
end proselect;
from test group by LNGACCOUNTID;
---------- -----------------
a 1000
a 2000
a 3000
b 4000
b 2500
b 1500已选择6行。SQL> SELECT a.lngaccountid, a.part / b.total AS per
2 FROM (SELECT lngaccountid, SUM (dblunvoucherdebit) AS part
3 FROM TEST
4 GROUP BY lngaccountid) a,
5 (SELECT SUM (dblunvoucherdebit) total
6 FROM TEST) b
7 /LNGACCOUNT PER
---------- ----------
a .428571429
b .571428571SQL> 我尝试过我的那个语句确实在817环境不能运行,大概是因为817中子查询不能作为
公式项出现?
上面这个保证是在标准817环境下测试的,可用。
select sum(DBLUNVOUCHERDEBIT) into total from accountdaily
select sum(DBLUNVOUCHERDEBIT)/total from accountdaily group by LNGACCOUNTID