Using PL/SQL Developer, I am attempting to basically unpivot some rows into columns, but am having a difficult time doing so. I think the solution would be to use a cross apply and then unpivot, but maybe I am approaching this the wrong way.
EDIT: From a very helpful comment, at most, an ID will have 5 rows to associated to it.
Input Table:
ID Date Location
111 1/05/2020 Cafe1
222 1/02/2020 Park1
222 1/11/2020 Cafe2
Output Table:
ID Date1 Location1 Date2 Location2
111 1/05/2020 Cafe1
222 1/02/2020 Park1 1/11/2020 Cafe2
Code Attempt:
SELECT *
FROM (
SELECT A.ID
,B.*
FROM MYTABLE as A
CROSS APPLY (Date, Location)
) B(Item,Value)
) src
PIVOT (max(value) for Item in ([Date], [Location])
I am running into some nasty errors, unfortunately. Any help/guidance to unpivot would be greatly appreciated - please and thank you!