title: Analytic function windowing clause
body: <p>Column VAL is a number list from 1 to 3, the other columns are supposed to show: </p>
  
  <ul>
  <li>A) MIN of all lower values than VAL </li>
  <li>B) MAX of all lower values than VAL</li>
  <li>C) MIN of all greater values than VAL</li>
  <li>D) MAX of all greater
  values than VAL</li>
  </ul>
  
  <p>I would expect this result:</p>
  
  <pre><code>V   A   B   C   D
  -------------------
  1 |   |   | 2 | 3
  2 | 1 | 1 | 3 | 3
  3 | 1 | 2 |   | 
  </code></pre>
  
  <p>But the result I get is: </p>
  
  <pre><code>V   A   B   C   D
  -------------------
  1 |   |   | 2 | 3
  2 |   |   |   |  
  3 |   |   |   | 
  </code></pre>
  
  <p>(*) All blank cells are NULL results</p>
  
  <p>The query I wrote:</p>
  
  <pre><code>WITH T AS
         (SELECT     CAST(LEVEL AS NUMBER) val
          FROM       DUAL
          CONNECT BY LEVEL &lt; 4)
  SELECT   val
          ,MIN(val) OVER(ORDER BY val RANGE BETWEEN UNBOUNDED PRECEDING AND val PRECEDING) A --MIN_PRECEDING
          ,MAX(val) OVER(ORDER BY val RANGE BETWEEN UNBOUNDED PRECEDING AND val PRECEDING) B --MAX_PRECEDING
          ,MIN(val) OVER(ORDER BY val RANGE BETWEEN val FOLLOWING AND UNBOUNDED FOLLOWING) C --MIN_FOLLOWING
          ,MAX(val) OVER(ORDER BY val RANGE BETWEEN val FOLLOWING AND UNBOUNDED FOLLOWING) D --MAX_FOLLOWING
  FROM     T
  WHERE    val IS NOT NULL
  ORDER BY 1
  /
  </code></pre>
  
  <p>Does anybody see what's wrong with this query?</p>
  
  <p>Thanks in advance!</p>