I am rewriting this question because the other one got closed. I have the following tables: enter image description here I need to write a query that produces the end of yea