Can anyone help or advise? I am new to Oracle I have this query which needs to be converted to a MySQL Query
with dset as (
select count(column_1) as Volumes, to_char(creation_date,'MM-YYYY') as
Month, REPLACE(record_type, 3, 2) as RecordType from
table_1 where
transaction_type = 'PG' and
category = 'CCB' and
trunc(creation_date) >= to_date(?1, 'DD/MM/YYYY') and
trunc(creation_date) <= to_date(?2, 'DD/MM/YYYY')
group by to_char(creation_date,'MM-YYYY'), REPLACE(record_type, 3, 2)
)
SELECT x.DateMonth
,MAX(DECODE(x.RecordType, '1', x.Volumes)) CONSUMER
,MAX(DECODE(x.RecordType, '2', x.Volumes)) COMMERCIAL
FROM (
SELECT r.DateMonth
,r.RecordType
,r.Volumes
FROM dset r
) x
GROUP BY x.DatetMonth
What would be the best approach to get this query working in MySQL.
Many Thanks