title: Lag() with condition in sql server
body: <p>i have a table like this:</p>
  
  <pre><code>Number   Price    Type       Date         Time
  ------   -----    ----    ----------    ---------
  23456    0,665     SV     2014/02/02     08:00:02
  23457    1,3       EC     2014/02/02     07:50:45
  23460    0,668     SV     2014/02/02     07:36:34
  </code></pre>
  
  <p>For each EC I need previous/next SV price. In this case, the query is simple.</p>
  
  <pre><code>Select Lag(price, 1, price) over (order by date desc, time desc),
  Lead(price, 1, price) over (order by date desc, time desc)
  from ITEMS
  </code></pre>
  
  <p>But, there are some special cases where two or more rows are EC type:</p>
  
  <pre><code>Number   Price    Type       Date         Time
  ------   -----    ----    ----------    ---------
  23456    0,665     SV     2014/02/02     08:00:02
  23457    1,3       EC     2014/02/02     07:50:45
  23658    2,4       EC     2014/02/02     07:50:45
  23660    2,4       EC     2014/02/02     07:50:48
  23465    0,668     SV     2014/02/02     07:36:34 
  </code></pre>
  
  <p>can I use Lead/Lag in this cases? If not, did I have to use a subquery? </p>