I'm trying to use listagg to group categories by date, but the field is date-time. Categories are appearing on separate lines. Is it possible to group by date only? I've tried CAST as well as DATE in the group by, but it's still not working. Here's the base query:
select ACCOUNT,
ID,
NAME,
TERM,
listagg(CATEGORY, ', ') within group (order by CATEGORY) as cat_by_date,
trunc(TRANSACTION_DATE) short_date
from TABLE
where term= '2022'
and CATEGORY in ('T', 'H', 'P')
group by
ACCOUNT_UID,
ID,
NAME,
TERM,
TRANSACTION_DATE
order by 1
CodePudding user response:
TRUNC in the GROUP BY as well
...
group by
ACCOUNT_UID,
ID,
NAME,
TERM,
TRUNC(TRANSACTION_DATE)
