[英]inner select statement not registering as a single-group function… “not a single-group group function”
I have to put everything in one sql statement for a report because of the reporting software I'm using. 由于我使用的报告软件,我必须将所有内容放在一个sql语句中以获取报告。 However, Oracle SQL doesn't seem to be letting me create an inner select with a single-group result even though it has only 1 result in the end product.
但是,即使最终产品中只有1个结果,Oracle SQL似乎也不允许我创建具有单组结果的内部选择。 (All the other results are single-group functions).
(所有其他结果均为单组函数)。 Here's my SQL:
这是我的SQL:
select
COUNT(*) as TOTAL_RXS,
SUM(rx_tx.brand_acquisition_cost) as TOTAL_COST,
SUM(case rx_tx.drug_dispensed
when 'B' then (rx_tx.brand_price - rx_tx.brand_discount)
when 'G' then (rx_tx.generic_price - rx_tx.generic_discount)
end)
as TOTAL_PRICE,
SUM(case rx_tx.drug_dispensed
when 'B' then (rx_tx.brand_price - rx_tx.brand_discount - rx_tx.brand_acquisition_cost)
when 'G' then (rx_tx.generic_price - rx_tx.generic_discount - rx_tx.brand_acquisition_cost)
end)
as TOTAL_PROFIT
, (select
SUM(tx_tp.balance_due_from_tp)
from eps2.tx_tp
join eps2.rx_tx on rx_tx.id = tx_tp.rx_tx_id
where 1=1
-- This results in CLAIM STATUS being 'F'
AND rx_tx.fill_date is not NULL
AND rx_tx.returned_date is not NULL
AND rx_tx.reportable_sales_date is NULL
AND (tx_tp.paid_status like '%PAID%'
OR tx_tp.paid_status like '%PART%') ) as TOTAL_RECEIVABLES
from eps2.vw_rx_summary join eps2.rx_tx
on vw_rx_summary.last_filled_rx_tx_id = rx_tx.id
-- where TRUNC(rx_tx.fill_date,'DD') = TRUNC(SYSDATE - 1,'DD')
Can anyone help me? 谁能帮我? Thanks in advance.
提前致谢。
select COUNT(*) as TOTAL_RXS,
SUM(rx_tx.brand_acquisition_cost) as TOTAL_COST,
MAX(select
SUM(tx_tp.balance_due_from_tp) as total_receivables
from eps2.tx_tp
join eps2.rx_tx on rx_tx.id = tx_tp.rx_tx_id
where 1=1
AND (tx_tp.paid_status like '%PAID%'
OR tx_tp.paid_status like '%PART%') ) as total_receivables
Adding a MAX()
for total_receivables
to mask it as a aggregate function! 为
total_receivables
添加一个MAX()
以total_receivables
其掩盖为聚合函数!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.