Hi! Below script show another error:
Error: ora-00923 from keyword not found where expected
WITH cte_month AS
(SELECT row_number() OVER(PARTITION BY to_char(r."balance_date", 'Month'), to_char(r."balance_date", 'Year') ORDER BY "balance_date" DESC) rownum,
arrears_in_days AS "arrears_in_days",
balance_date AS "balance_date",
acct_id AS "acct_id"
FROM report r
where r."acct_id" = '11002140008598'
and (to_char(r."balance_date", 'D')) not in (6, 7))
select xmlserialize(content "arrears_in_days" as clob)
from ( select * from cte_month )
pivot xml
(
max("arrears_in_days")
for ("balance_date")
in (select distinct "balance_date" from cte_month)
);