I have two tables: fund and items. Items has a field called fundID that is related to the ID of the fund table. Items also has a price field.
Here’s a simplified example of the two tables:
FUND
ID fundName
1 maintenance
2 books
3 development
4 media
ITEMS
ID price fundID
1 $10 2
2 $20 4
3 $5 4
4 $8 1
5 $10 3
6 $12 4
I want to create a query that will give me the name of each fund and the sum of all prices for items that are connected to that fund through the fundID field. I have tried several methods such as having a correlated subquery within the SUM() and also within the WHERE, and I am getting errors.
If someone could point me in the right direction, I’d appreciate it.
Try this :