Oracle Implementation query A detailed example of basic information for employees in each department

Source: Internet
Author: User
--Delete the original table: Drop table emp;--CREATE table empcreate table emp (     deptno number,     ename varchar2 (), Sal number     );-- Insert data--Department 1 Employee information INSERT into EMP values (1, ' King Hee 1 ', 15000); INSERT into EMP values (1, ' King Hee 2 ', "); INSERT into EMP values (1, ' Wang Hee 3 ', 115000); INSERT into EMP values (1, ' King Hee 4 ', 12300);--Department 2 employee information INSERT into EMP values (2, ' king haha ', 14300); INSERT INTO EMP VALUES (2, ' King hehe ', 16300); INSERT into EMP values (2, ' Wang Yu ', 11300); INSERT into EMP values (2, ' King Big ', 10300); select * FROM emp;-- Select the top 3 highest wage people for each department select * from       (select Deptno,ename,sal,               row_number () over (                            partition by Deptno                            ORDER by SAL (DESC) rn from                            emp       )       where rn<=3;

Run as follows:


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Oracle Implementation query A detailed example of basic information for employees in each department

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.