I can't figure out a query that will add and compare across tables. I have three tables:
house
id
-----
1
2
month
id | house_id | btus
---------------------
3 | 1 | 100
4 | 2 | 200
car
id | month_id | btu
--------------------------
5 | 3 | 10
6 | 4 | 20
7 | 3 | 15
I need a query that will return the house ids sorted by total btus for the month and car.
So for the above example it would return 2,1 as (200+20) > (100 + 10 + 15)