1
我收到以下查詢,告訴我缺少右括號。沒有第一選擇和LISTAGG內子查詢工作完美,但是當我添加缺少右括號oracle sql
SELECT audit_date, charge_type, customer_no, nam, result,
LISTAGG(charge_type, ',') WITHIN GROUP (ORDER BY charge_type desc) charge_name
它告訴我 - 缺少右括號,雖然我沒有看到錯誤。
查詢:
SELECT audit_date, charge_type, customer_no, nam, result,
LISTAGG(charge_type, ',') WITHIN GROUP (ORDER BY charge_type desc) charge_name
FROM
(
SELECT audit_date, charge_type, customer_no, name nam, sum(amount) result
FROM
(
select
CASE
WHEN i.charge_type = 'GSMUsageCharge' THEN 'GSMUsageCharge'
ELSE i.charge_type
END charge_type,
CASE
WHEN i.charge_type='GSMUsageCharge' AND cp.name='Service Charges' THEN 'Call Charges'
ELSE cp.name
END name,
i.amount amount, s.audit_date, cu.customer_no, g.mobile_no
from charge.gp_schedule gp, charge.gsm_charge_plan cp, ledger.sales_audit s,
ledger.invoice_item i, service.gsm g, service.contract c,
ccare.customer cu, charge.gsm_fixed_charge gfc
where s.code = i.sales_audit_code
and i.charge_plan_code = gp.charge_plan_code
and gp.charge_plan_code = cp.code
and cp.service_code = g.code
and g.contract_code = c.contract_no
and c.customer_code = cu.customer_no
and gfc.code(+) = gp.charge_code
and s.type_code = 'IR'
) modified_names
group by audit_date, customer_no, charge_type, name;
) res
GROUP BY audit_date, charge_type, customer_no, nam, result;
'name'後面還有一個分號,用於結束查詢。 – GolezTrol