Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1417859
  • 博文数量: 239
  • 博客积分: 5909
  • 博客等级: 大校
  • 技术积分: 2715
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-24 20:19
文章分类

全部博文(239)

文章存档

2014年(4)

2013年(22)

2012年(140)

2011年(14)

2010年(59)

我的朋友

分类: Oracle

2013-11-25 15:34:03


  1. select level, max('col_name') from my_table
  2. where level = '&n'
  3. connect by prior ('col_name') > 'col_name')
  4. group by level;

  5. -- Example :
  6. --
  7. -- Given a table called emp with the following columns:
  8. -- id number
  9. -- name varchar2(20)
  10. -- sal number
  11. --
  12. -- For the second highest salary:
  13. --
  14. -- select level, max(sal) from emp
  15. -- where level=2
  16. -- connect by prior sal > sal
  17. -- group by level

  1. select level, min('col_name') from my_table
  2. where level = '&n'
  3. connect by prior ('col_name') < 'col_name')
  4. group by level;


  5. -- Example:
  6. --
  7. -- Given a table called emp with the following columns:
  8. -- id number
  9. -- name varchar2(20)
  10. -- sal number
  11. --
  12. -- For the second lowest salary:
  13. --
  14. -- select level, min(sal) from emp
  15. -- where level=2
  16. -- connect by prior sal < sal


阅读(741) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~