Hi Team,
i have table in this table has item startdate and qty
item startdate qty
it1 22-07-2023 10
it2 22-07-2023 20
it3 22-07-2023 20
it1 23-07-2023 10
it2 23-07-2023 20
i want below output
item 22-07-2023 22-07-2023
it1 10 10
it2 20 20
it3 20 0
I tried the query below, but it's not working. The FOR startdate is provided as hardcoded. Is there any automatic way to generate the dates dynamically? Please help me.
SELECT *
FROM (
SELECT item, startdate, qty
FROM valid_details
)
UNPIVOT (
qty FOR startdate IN (DATE '2023-07-22' AS "22-07-2023", DATE '2023-07-23' AS "23-07-2023")
)
ORDER BY item, startdate;
Thanks