title: How to fetch last two year annual data in oracle
body: <p>There is table named sales_data which i used for my project.The table structure is below.</p>
  
  <pre>
  ID  Name    Year    Sales
  1000    ABC 2016    50000
  1000    ABC 2017    80000
  1000    ABC 2015    90000
  1000    ABC 2014    45000
  1000    ABC 2013    30000
  2000    PQR 2017    80000
  2000    PQR 2015    90000
  2000    PQR 2014    75000
  2000    PQR 2013    60000
  3000    XYZ 2015    123000
  3000    XYZ 2013    56000
  3000    XYZ 2012    45000
  3000    XYZ 2011    30000
  </pre>
  
  <p>from this table. I want to fetch latest consecutive annual data. My result set is need to be like below</p>
  
  <pre>
  ID  Name    Year    Sales
  1000    ABC 2017    80000
  1000    ABC 2016    50000
  2000    PQR 2017    80000
  2000    PQR 2016    0
  3000    XYZ 2015    123000
  3000    XYZ 2014    0
  </pre>
  
  <p>because for PQR company lastest data is 2017 so it is 80000 but 2016 data is not present in this table so it's need to be 0.
  Similar for XYZ company also.</p>
  
  <p>Please help me on that. I am using Oracle 11g.</p>