0

I have table such as

| work_order_id | part_number | due_date   |
|: 1            |:P123:       | 2022-03-04:|
|: 2            |:P123:       | 2022-03-11:|
|: 3            |:P123:       | 2022-04-02:|

Essentially I wanted to create a view where the first and third rows are aggregated by the order of the second column. So the resulting view should look like:

|: {1,2,3}|:P123:| {2022-04-2, 2022-03-11, 2022-04-2:|
1

1 Answer 1

0

The Aggregrate function ARRAY_AGG() seems to be what you're after.

SELECT ARRAY_AGG(work_order_ID ORDER BY work_order_ID) as WorkorderIDs
     , part_number
     , ARRAY_AGG(due_Date ORDER BY work_order_ID) as due_dates
FROM yourTableName
GROUP BY part_number
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.