title: SQL join table to itself to get data for previous year
body: <p>SQL. How can I join table to itself to get desired results just as shown in the table below. The logic is that I want to have Units for the same product and corresponding month of previous year.</p>
  
  <p>The simple left join on source table to itself on key <code>a.[year]=b.[year]+1</code> (and of course month to month and product to product) would cause the loss of the data where we had values in the previous year and do not have now.</p>
  
  <p><a href="https://i.stack.imgur.com/0uyFf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0uyFf.png" alt="enter image description here"></a></p>