title: sql query to show matrix of each year an employee was working for the company
body: <p>Data</p>
  
  <p><a href="https://i.stack.imgur.com/WC697.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WC697.png" alt="enter image description here"></a></p>
  
  <p>expected Output</p>
  
  <p><a href="https://i.stack.imgur.com/evrte.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/evrte.png" alt="enter image description here"></a></p>
  
  <p>write a script that will create a matrix (expected output) with years on the x-axis and employee id on the y-axis. The purpose of this matrix is to show each year an employee was working for the company.<br>
  Guidelines:<br>
  -   The script should be dynamic and no hard coded values are allowed. 
  -   If we add more data to the table, the script should automatically pick that up and expand the matrix accordingly. 
  -   The matrix should always display the data till the current year + 1. So for example, the current year now is 2016 and the matrix should extend till 2017. 
  -   For employees that are still active, they will show as active for all the future years. </p>
  
  <p>above is the problem.First image is data and second image is expected output</p>
  
  <p>I am a beginner to sql. Any help is appreciated. I have been trying this for 2 days but could got no luck!!</p>