oracle語句練習
阿新 • • 發佈:2018-11-04
1.檢視該公司的員工分佈在哪幾個部門
select distinct deptno from emp;
2.檢視每個部門有哪些崗位
select distinct deptno , job from emp order by deptno;
3.查詢工資每月1600的員工姓名和工作崗位
select ename ,job,sal from emp where sal=1600;
4.查詢姓名為SMITH的所有資訊
select * from emp where ename = 'SMITH';
5.查詢每月工資大於1500的員工姓名及薪資
select ename ,sal from emp where sal>1500; select ename ,sal from emp where sal>1500 order by sal;
6.查詢工資在2000到3000之間的職員資訊
select ename,sal,job from emp where sal between 2000 and 3000 order by sal;
7.查詢沒有獎金的員工的資訊 IS NULL
select ename,sal,job ,comm from emp where comm is null or comm=0;
8.查詢有獎金的員工的資訊 IS NOT NULL
select ename,sal,job ,comm from emp where comm is not null and comm!=0;
9.查詢部門是30而且工資超過1300的員工資訊
select ename , deptno , sal from emp where deptno = 30 and sal >1300;
10.查詢工資為1300,1500,3000的員工的資訊(使用or)
select ename , sal from emp where sal=1300 or sal = 1500 or sal = 3000;
11.查詢工資為1300,1500,3000的員工的資訊(使用in)
select ename , sal from emp where sal in(1300,1500,3000);
12.查詢名字是A打頭的員工資訊
select ename from emp where ename like 'A%';
13.查詢名字裡邊包含AR的員工的資訊
select ename from emp where ename like '%AR%';
14.查詢名字以D結尾的員工的資訊
select ename from emp where ename like '%D';
(1)按照薪資從低到高的順序查詢所有員工資訊
select ename ,sal from emp order by sal;
(2)檢視30部門的員工按薪資從高到低
select ename , deptno ,sal from emp where deptno = 30 order by sal desc;
(3)檢視員工資訊按照部門編號從低到高,再按照薪資從高到低
select ename , deptno,sal from emp order by deptno asc ,sal desc;