title: PARTITION BY with and without KEEP in Oracle
body: <p>I came across two queries which seems to have the same result: applying aggregate function on partition. </p>
  
  <p>I am wondering if there is any difference between these two queries:</p>
  
  <pre><code>SELECT empno,
     deptno,
     sal,
     MIN(sal) OVER (PARTITION BY deptno) "Lowest",
     MAX(sal) OVER (PARTITION BY deptno) "Highest"
  FROM empl
  
  SELECT empno,
     deptno,
     sal,
     MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
     MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
  FROM empl
  </code></pre>
  
  <p>The first version is more logical but second one may be some kind special case, maybe some performance optimization.</p>