我有以下查询,我想要输出 一行用分隔符 | 分隔我的数据:
WITH X AS (
SELECT 'WLT_CUSTOMER' AS TABLE_NAME_STAGING_AREA,
COUNT(*) as TOTAL_WLT_CUSTOMERS
FROM WLT_CUSTOMER
where WLT_DATE = (SELECT SCHEDULED_DATE FROM BANK_PARAMETERS)
UNION ALL
SELECT 'CUSTOMER' AS TABLE_NAME_PRODUCTION_DATABASE,
COUNT(*) as TOTAL_CUSTOMERS
FROM CUSTOMER
where CUST_ID <> 0
)
SELECT X.TABLE_NAME_STAGING_AREA
|| '|'
|| X.TOTAL_WLT_CUSTOMERS
|| '|'
|| X.TABLE_NAME_PRODUCTION_DATABASE
|| '|'
|| X.TOTAL_CUSTOMERS
FROM X
它给我错误ORA-00904:“ X”。“ TOTAL_CUSTOMERS”:无效的标识符。
预期输出应该是这样的: WLT_CUSTOMER | 10 |客户| 30
有什么想法吗? 预先感谢!
答案 0 :(得分:1)
select 'WLT_CUSTOMER'||'|'||(
select COUNT(*) as TOTAL_WLT_CUSTOMERS
FROM WLT_CUSTOMER
where WLT_DATE = (SELECT SCHEDULED_DATE FROM BANK_PARAMETERS))
||'|'||'CUSTOMER'||'|'||
(select COUNT(*) as TOTAL_CUSTOMERS
FROM CUSTOMER
where CUST_ID <> 0) from dual;