`
ktnd
  • 浏览: 17297 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

How to make aggregate function work on non-sort key

阅读更多

"When you need a value from the first or last row of a sorted group, but the needed 

value is not the sort key, the FIRST and LAST functions eliminate the need for 

self-joins or views and enable better performance."

 

SELECT department_id,
MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) "Worst",
MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct) "Best"
   FROM employees
   GROUP BY department_id;

 

From Oracle Document

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics