I have a table which has the following structure and sample data:
VENDOR | ORDER | DELIVERY_DATE | REMARKS | USER |
---|---|---|---|---|
PEPSI | 1122 | 20-DEC-22 | OPENED | John |
PEPSI | 1122 | 22-DEC-22 | REQUESTED | Martin |
PEPSI | 1122 | 26-DEC-22 | IN PROCESS | Wyatt |
PEPSI | 1122 | 10-JAN-23 | DELAYED | Khabib |
PEPSI | 1122 | 22-JAN-23 | IN TRANSIT | Karen |
Table could contain different VENDORs and ORDERs. I need to display in one row data for each order and vendor. Like this:
VENDOR | ORDER | DELIVERY_DATE_1 | REMARKS_1 | USER_1 | DELIVERY_DATE_2 | REMARKS_2 | USER_2 | DELIVERY_DATE_3 | REMARKS_3 | USER_3 |
---|---|---|---|---|---|---|---|---|---|---|
PEPSI | 1122 | 20-DEC-22 | OPENED | John | 22-DEC-22 | REQUESTED | Martin | 26-DEC-22 | IN PROCESS | Wyatt |
etc
I've tried PIVOT, but it does not work:
SELECT VENDOR,
order_number,
-- delivery_date,
pickup_date
reasonf_of_delay,
user_name
from table
PIVOT
(count(delivery_date)
FOR order_number
)