Oracle Group Query subquery statistics query from plus subquery temporary table query above average wage sample code

Source: Internet
Author: User
Tags dname

---average wageSELECT AVG(SAL) fromEMP;-----------greater than average salarySELECTE.ename,e.job,e.sal fromEMP EWHEREE.sal>(SELECT AVG(SAL) fromEMP)----------e leader Number =m employee number--EMP Employee table, Dept Department tableSELECTE.ename Employee name, e.job employee position, e.sal employee salary, M.ename leadership name, m.job leadership position, D.dname department name fromEMP e,emp m,dept DWHEREE.sal>(SELECT AVG(SAL) fromEMP) andE.mgr=M.empno (+) andE.deptno=D.deptno-----------Plus from subquery statement, number of statisticiansSELECTE.ename Employee name, e.job employee position, e.sal employee salary, M.ename leadership name, m.job leadership position, D.dname department name, Dtemp.CountNumber of Departments fromEMP e,emp m,dept D, (SELECTDeptno DNO,COUNT(empno)Count fromEMPGROUP  bydeptno) DtempWHEREE.sal>(SELECT AVG(SAL) fromEMP) andE.mgr=M.empno (+) andE.deptno=D.deptno andDtemp.dno (+)=D.deptno----Add a salary scale. Salary LevelSELECTE.ename Employee name, e.job employee position, e.sal employee salary, M.ename leadership name, m.job leadership position, D.dname department name, Dtemp.Countnumber of departments, S.grade wage level fromEMP e,emp m,dept D, (SELECTDeptno DNO,COUNT(empno)Count fromEMPGROUP  bydeptno) Dtemp,salgrade sWHEREE.sal>(SELECT AVG(SAL) fromEMP) andE.mgr=M.empno (+) andE.deptno=D.deptno andDtemp.dno (+)=D.deptno andE.salbetweenS.losal andS.hisal--61m-----Number of people using this wage levelSELECTS1.grade SG,COUNT(E1.empno)Count fromEMP e1,salgrade S1WHEREE1.salbetweenS1.losal andS1.hisalGROUP  byS1.grade--Seventh-Number of people embedding wage levels, grouped by S1.grade----SELECTS1.grade SG,COUNT(E1.empno)Count fromEMP e1,salgrade S1WHEREE1.salbetweenS1.losal andS1.hisalGROUP  byS1.grade;----Complete bodySELECTE.ename Employee name, e.job employee position, e.sal employee salary, M.ename leadership name, m.job leadership position, D.dname department name, Dtemp.Countnumber of departments, S.grade wage level, stemp.CountRank number--m leader, fromEMP e,emp m,dept D, (SELECTDeptno DNO,COUNT(empno)Count fromEMPGROUP  bydeptno) Dtemp,--number of DTEMP departmentsSalgrade S, (SELECTS1.grade SG,COUNT(E1.empno)Count fromEMP e1,salgrade S1WHEREE1.salbetweenS1.losal andS1.hisalGROUP  bys1.grade) Stemp--stemp wage level numberWHEREE.sal>(SELECT AVG(SAL) fromEMP) andE.mgr=M.empno (+) andE.deptno=D.deptno andDtemp.dno (+)=D.deptno andE.salbetweenS.losal andS.hisal andS.grade=stemp.sg; 

Oracle Group Query subquery statistics query from plus subquery temporary table query above average wage sample code

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.