This works because of an inline view (marked in red) which acts as a temporary table holding the value for each row :

Result Set 3

Material_id

Year

Value

TX002

1/1/2013

$360

TX003

1/1/2013

$680.01

and exporting material_id and year to the outside scope, both of which will subsequently used for joining with the Accounts table of the outer query ( a.material_id = b.material_id and a.year = b.year), producing :

Result Set 4

Account_category

Account_id

Value

01

220201511

$360

01

220201511

$680.01

and finally grouped into :

Result Set 5

Account_category

Account_id

Summed_amount

01

220201511

$1040.01

enabling us to answer questions like “how much money on average, did the consumption of fruit cost us this year?”, so that we can estimate how much money we should reserve for next year’s purchases.