This was the hardest problem I've ever had with Google Sheets queries - joining two tables together, like a regular database.
I finally cracked it, with the help of a blog reader - this trick will let you join two tabs of data together:
=query(tab1!A:Z,"select A,sum(B) where A != '' and (B = 'All' " & concatenate(arrayformula(" OR B = '" & tab2!C2:C & "'")) & ") group by B",0)
For more background on the Query function, grab a copy of the Google Sheets formula cheat sheet at:
https://trello.com/c/b2q3P0E3/39-10-key-google-sheets-formulas