• Could be me, but I think you're making this infinitely harder than it really needs to be. If you think in terms of SETS and use pure SQL, you can do it easily.

    Question 1:

    Write an SQL statement that will perform a daily sum aggregation on the field cost. It must only use costs that are associated with the follow items: Z001, Z002. The cost must also only come from division 1. Below is the example table that you will be retrieving data from:

    It's a SUM and a couple of filters... sorry, but you gotta stretch a little. That's what homework is for.