I have a scenario where iI have to pivot a list of rows to columns dynamically .For a particular order_numberorder_number
there might be several products,product
s. I want all those products to be in a separate column, along with its products id thatproduct_id
(that too in columns), but we cannot predict how many products will there for a particular order_numberorder_number
.
Attaching a sample input table and desired output.I'm using postgreSQL and I have tried crosstabthe crosstab
function but the resultsresult is not correct.
Desired Ouput: