Having tables like:
sold_items:
code | size | quantity
abc123 | small | 4
abc123 | medium | 2
xyz987 | small | 3
xyz987 | medium | 1
xyz987 | large | 2
price_list:
code | size | price
abc123 | small | 5
abc123 | medium | 7
abc123 | large | 9
xyz987 | small | 10
xyz987 | medium | 13
xyz987 | large | 15
which would be your best (faster query) approach to get
results:
code | sold_items | cash
abc123 | 6 | 34
xyz987 | 6 | 73
Try this out please.
Code:
Results:
This should work: