在oracle报表查询中使用select in select
我正在创建一份新报告,其中报告中只有一个光标,并且该报告没有纸张布局(它直接转为 CSV 格式)。
我有一个查询,我需要进行子查询,例如
SELECT
grou.GROUP_ID GROUP_ID
,grou.group_name group_name
....
(((SELECT SUM(nett_instalment_invoice_amount)
FROM instalments
WHERE member_product_id = member_product_id)) subscription)
FROM
...... 等等......
在编译报告时,我遇到一个错误,提示
Encountered Symbol SELECT while expecting one of the following symbols:
( + -
如果不在最后添加 group by 子句,这是否可以得到帮助?
当我尝试另一种方法时,放入 group by 子句并直接使用 sum 函数而不是 select (sum())。
请紧急需要帮助。
谢谢。
I am creating a new report where I have only one cursor in the report and the report has no paper layout (it goes directly to a CSV format).
I have a query where I need to make a sub query something like
SELECT
grou.GROUP_ID GROUP_ID
,grou.group_name group_name
....
(((SELECT SUM(nett_instalment_invoice_amount)
FROM instalments
WHERE member_product_id = member_product_id)) subscription)
FROM
....
and so on....
While compiling report I encounter an error saying
Encountered Symbol SELECT while expecting one of the following symbols:
( + -
can this be helped without adding a group by clause at the end?
As I tried an alternative approach by putting in a group by clause and directly using sum function instead of select (sum()).
Please urgent help needed.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个简单的解决方法,通过创建一个函数,让我们将其称为 get_installment_inv_sum ,并带有一个参数 member_product_id ,如下所示:
然后您可以像这样调用您的选择:
there is a simple workaround for this by creating a function let's call it get_installment_inv_sum with one parameter member_product_id like this:
then you can call your select like:
这当然是允许的:
那么这也是:
那么你到底做了什么?
This is certainly allowed:
And so is this:
So what did you do exactly?
Oracle 报告是哪个版本?
标量子查询语法在 Oracle 8/8i 左右出现,但 Oracle 报告的开发在石器时代的某个时候就停止了。过去 10 多年的许多增强的 SQL 语法还没有出现。
如果您可以将大部分查询创建为数据库中的视图,并且只需从报表中的视图中进行选择,那么您就可以获得更多灵活性
Which version of Oracle Reports ?
The scalar subqueries syntax came in around Oracle 8/8i, but the development of Oracle reports stopped sometime around the stone-age. A lot of the enhanced SQL syntax of the last 10+ years hasn't made it in.
If you can create the bulk of the query as a view in the database, and just select from the view in the report, then you have more flexibility