I'm getting the missing keyword error ORA-00905 for the query
SELECT '01_AMT' AS FIELD, COUNT((NVL(AMT,0)) AS CNT FROM TBL1
UNION ALL
SELECT
CASE
WHEN AMT IS NULL THEN 'NULL'
WHEN AMT<10000 THEN '<10000'
WHEN AMT>= 10000 and AMT<=59999 THEN '10,000-59,999’
ELSE '60,000up' END,
COUNT (1) CNT FROM TBL1
GROUP BY CASE
WHEN AMT IS NULL THEN 'NULL'
WHEN AMT<10000 THEN '<10000'
WHEN AMT>= 10000 and AMT<=59999 THEN '10,000-59,999’
ELSE '60,000up' END
output:
FIELD CNT
01_Amt 100000
10,000-59,999 50000
60,000up 50000
The first field '01-Amt' should have the total count and breakdown of the other counts from the second row. Amt is number datatype.