当前位置:首页 > 开发 > 数据库 > 正文

查询工资排名前三的员工姓名和工资(sql和plsql两种方法实现)

发表于: 2010-12-24   作者:空谷悠悠   来源:转载   浏览:
sql
摘要: select ename,sal from emp where empno in (select empno from (select empno,sal from emp order by sal desc )t where rownum<4);   declare v_name varchar2(10); v_sal number(5);
select ename,sal from emp where 
   empno in (select empno from (select empno,sal from emp order by sal desc )t
   where rownum<4);

 

declare 
  v_name varchar2(10);
  v_sal number(5);
  cursor emp_cursor is select ename,sal from emp order by sal desc;
  begin 
  open emp_cursor;
  for i in 1..3
  loop
  fetch emp_cursor into v_name,v_sal;
  dbms_output.put_line(v_name||','||v_sal);
  end loop;
  close emp_cursor;
  end;

 

查询工资排名前三的员工姓名和工资(sql和plsql两种方法实现)

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号