oracle子查詢

來源:互聯網
上載者:User

標籤:子查詢

--公司平均工資  單行單列

--select avg(sal) from emp;

--找到高於此平均工資的僱員姓名、職位、工資

--select e.ename,e.job,e.sal

--from emp e

--where e.sal >(select avg(sal) from emp);

--領導姓名

--select e.ename,e.job,e.sal,m.ename,m.job

--from emp e,emp m,dept d

--where e.sal >(select avg(sal) from emp)

--and e.mgr=m.empno(+) and e.deptno=d.deptno;

--部門名稱

--select e.ename,e.job,e.sal,m.ename,m.job,d.dname

--from emp e,emp m,dept d

--where e.sal >(select avg(sal) from emp)

--and e.mgr=m.empno(+) and e.deptno=d.deptno;

--部門人數

select e.ename,e.job,e.sal,m.ename,m.job,d.dname,dtemp.count,s.grade,stemp.cou

from emp e,emp m,dept d,(select deptno dno,count(empno) count from emp group by deptno)dtemp,salgrade s,(select s1.grade sg,count(e1.empno) cou

from emp e1,salgrade s1

where e1.sal between s1.losal and s1.hisal

group by s1.grade) stemp

where e.sal >(select avg(sal) from emp)

and e.mgr=m.empno(+) and e.deptno=d.deptno

and dtemp.dno=d.deptno

and e.sal between s.losal and s.hisal

and stemp.sg=s.grade;








本文出自 “10281302” 部落格,請務必保留此出處http://10291302.blog.51cto.com/10281302/1695268

oracle子查詢

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.