'Oracle sql - aggregates
I have the following data set:
CUST_ORD_NO ITEM STATUS
5451104 100004132 Fulfilled
5451104 100182935 Unfulfilled
5451105 100004132 Fulfilled
5451105 100182935 Fulfilled
I want to show result as:
CUST_ORD_NO STATUS
5451104 Unfulfilled
5451105 Fulfilled
If the order has any Item has Status of Unfulfilled, it should say as Unfulfilled If the order has all the Item as Fulfilled, it should say as Fulfilled
Solution 1:[1]
Take the MAX of the status column by cust_ord_no.
SELECT cust_ord_no, MAX(status) AS status
FROM t
GROUP BY cust_ord_no;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | FlexYourData |
