如何对 oracle apex 集合中的列求和

发布于 2025-01-10 07:27:22 字数 423 浏览 1 评论 0原文

所以我试图输出集合中一列的总计。

这是我尝试的第一个查询

select sum(C007),sum(C007) A FROM APEX_COLLECTIONS WHERE COLLECTION_NAME='PURCHASE'

这是我尝试的第二个查询

select sum(C005*C007),sum(C005*C007) A FROM APEX_COLLECTIONS WHERE COLLECTION_NAME='PURCHASE'

两者都产生相同的结果,列出了列中的所有值,而不是求和

预期结果:

10

实际结果:

2
2
2
2
2

请帮助

So I am trying to output the total of a column from a collection.

This is the first query I tried

select sum(C007),sum(C007) A FROM APEX_COLLECTIONS WHERE COLLECTION_NAME='PURCHASE'

This is the second query I tried

select sum(C005*C007),sum(C005*C007) A FROM APEX_COLLECTIONS WHERE COLLECTION_NAME='PURCHASE'

Both produce the same result which list out all the values in the column insted of suming them

Expected Results:

10

Actual Results:

2
2
2
2
2

Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世晨晓 2025-01-17 07:27:22

看来你做错了什么。

我创建了示例页面;它包含一个按钮(仅提交页面)和一个显示总计(集合值的总和)的项目。项目由包含所有内容的进程填充(为简单起见):

if not apex_collection.collection_exists('PURCHASE') then
   apex_collection.create_collection('PURCHASE');
end if;

apex_collection.add_member(
  p_collection_name => 'PURCHASE',
  p_c001            => 'Little',
  p_c007            => 100);              --> 100 ...
apex_collection.add_member(
  p_collection_name => 'PURCHASE',
  p_c001            => 'Foot',
  p_c007            => 200);              --> ... + 200 = 300

select sum(c007)
  into :P7_TOTAL
  from apex_collections
  where collection_name = 'PURCHASE';

运行时(按下按钮后),项目的值是 - 正如预期的 - 300

输入图片此处描述

Looks like you did something wrong.

I created sample page; it contains a button (which will just submit the page) and an item which will display total (sum of collection's values). Item gets populated by a process which contains everything (for simplicity):

if not apex_collection.collection_exists('PURCHASE') then
   apex_collection.create_collection('PURCHASE');
end if;

apex_collection.add_member(
  p_collection_name => 'PURCHASE',
  p_c001            => 'Little',
  p_c007            => 100);              --> 100 ...
apex_collection.add_member(
  p_collection_name => 'PURCHASE',
  p_c001            => 'Foot',
  p_c007            => 200);              --> ... + 200 = 300

select sum(c007)
  into :P7_TOTAL
  from apex_collections
  where collection_name = 'PURCHASE';

When ran (and after button was pressed), item's value is - as expected - 300.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文