title: Get the least closest value
body: <p>I have the following data</p>
  
  <pre><code>Docnum      ItemCode       opnum          startdate         result
  73305        Wc-Trim        100          2017-08-18       2017-08-18
  73305        WC-Asse        200          2017-11-29       2017-08-18
  73305        Wc-id          300          2017-11-30       2017-11-29
  73305        wc-qa          400          2017-12-01       2017-11-30
  </code></pre>
  
  <p>I need to get the output as shown in result column. 
  Explanation: 
  1.Opnum 100 is the first operation so the date is the same as that of the start date .
  2.For opnum 200 it has to get the startdate of opnum 100
  3.For opnum 300 it hs to get the startdate of opnum 200
  and so on.</p>
  
  <p>NOTE:The opnum are not always in the multiples of 100.
  with my query i get the startdate of opnum 100 for all the rows. </p>
  
  <p>Query :</p>
  
  <pre><code>select t0.DocNum,t1.itemcode,t1.U_SES_OP_NUM,t1.U_SES_DATESTART
  ,(select top 1 a0.U_SES_DATESTART from wor1 a0 where 
  t1.DocEntry = a0.DocEntry  and a0.ItemType = 290 and
  a0.U_SES_OP_NUM &lt; t1.U_SES_OP_NUM)
  
  from OWOR t0inner join WOR1 t1 on t0.DocEntry = t1.DocEntry and t1.ItemType = 290
  
  where t0.docnum = 73305
  order by t1.U_SES_OP_NUM
  </code></pre>