TWO TABLES
ORDER_TABLE:
ORDER_ID | TARGET_QTY |
-----------------------
1 | 50
2 | 100
3 | 200
ALLOC_TABLE:
ORDER_ID | TARGET_QTY |
-----------------------
1 | 50
2 | 20
2 | 30
3 | 200
I want to return ORDER_TABLE.ORDER_ID's where the SUM(ALLOC_TABLE.TARGET_QTY) for an order ID is < ORDER_TABLE.TARGET_QTY. Ex. of desired output below:
ORDER_ID |
---------
2
All help is appreciated!