I have table a and b.
- a has order_id and ship_total
- b has order_id, item, qty, and price
How do I query and get the sum of all ship_total on all orders that have a total qty under 100?
I am afraid if I do something like this, it’s going to be wrong.
select SUM(ship_total) FROM a as a inner join b as b on a.order_id=b.order_id WHERE SUM(qty) < 100 GROUP BY a.order_id
Any help would be greatly appreciated!
I’ve tried the answers from below and it’s not adding everything together. It’s giving me the shipping amount from each order.
One way:
Another way:
Try each out and see which performs best for you.