title: How to use LEAD and LAG In Where?
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
  23461    0,668     SV     2014/02/02     07:37:34
  23462    0,668     SV     2014/02/02     07:38:34
  23463    0,668     SV     2014/02/02     07:39:34
  </code></pre>
  
  <p>For each record I need previous/next  price. In this case, the query is simple.</p>
  
  <pre><code>Select Lag(price) over (order by date desc, time desc),
  Lead(price) over (order by date desc, time desc)
  from ITEMS
  </code></pre>
  
  <p>but i need the result Where Next price &lt;> record price</p>
  
  <p>My Query is</p>
  
  <pre><code>    Select Lag(price) over (order by date desc, time desc) Nxt_Price,
      Lead(price) over (order by date desc, time desc) Prv_Price
      from ITEMS
   Where Nxt_Price &lt;&gt; price
  </code></pre>
  
  <p>but it refused to use that variable </p>