Oracle查詢基礎練習____Oracle

來源:互聯網
上載者:User

1) 選擇在部門 30 中員工的所有資訊
2) 列出職位為(MANAGER)的員工的編號,姓名
3) 找出獎金高於工資的員工
4) 找出每個員工獎金和工資的總和
5) 找出部門 10 中的經理(MANAGER)和部門 20 中的普通員工(CLERK)
6) 找出部門 10 中既不是經理也不是普通員工,而且工資大於等於 2000 的員工
7) 找出有獎金的員工的不同工作
8) 找出沒有獎金或者獎金低於 500 的員工
9) 顯示僱員姓名,根據其服務年限,將最老的僱員排在最前面

10) 分組統計各部門下工資>500 的員工的平均工資、
11) 統計各部門下平均工資大於 500 的部門
12) 算出部門 30 中得到最多獎金的員工獎金
13) 算出部門 30 中得到最多獎金的員工姓名
14) 算出每個職位的員工數和最低工資
15) 列出員工表中每個部門的員工數和部門 no
16) 得到工資大於自己部門平均工資的員工資訊
17) 分組統計每個部門下,每種職位的平均獎金(也要算沒獎金的人)和總工資(包括獎金)

代碼:

1、select*from dept where deptno = 30;
2、select empno ,ename from emp where job=’MANAGER’;
3、select ename from emp where comm>sal;
4、select ename,sal*13+nvl(comm,0)*13 “年獎金和工資總和” from emp;
5、select ename from emp where (deptno=10 and job=’MANAGER’) or (deptno=20 and job=’CLERK’);
6、select ename from emp where (deptno=10 and job not in(‘MANAGER’,’clerk’) and sal>=2000);
7、select distinct job from emp where deptno>0;
8、select ename from emp where comm<500 or comm=0;
9、select ename,hiredate from emp order by (hiredate);
10、Select avg(sal) from emp where sal>500 group by deptno ;
11、select deptno,avg(sal) from emp group by deptno having avg(sal)>500 ;
12、select max(comm) from emp where deptno = 30;
13、select ename from emp where comm = (select max(comm) from emp where deptno = 30);
14、select job,count(*),min(sal) from emp group by job;
15、select count(*),deptno from emp group by deptno;
16、select * from emp e1,(select deptno,avg(sal) as avgsal from emp group by deptno) e2
where e1.deptno=e2.deptno and e1.sal > e2.avgsal;

17、select deptno,job,avg(nvl(comm,0)),sum(sal+nvl(comm,0)) from emp group by deptno,job;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.