SQL练习0603
?
?
二、練習
1. 查詢出部門編號為30的所有員工
Select * from where deptno = 30;
2. 所有銷售員的姓名、編號和部門編號。
Select ename,mgr,deptno from ygb;
3. 找出獎金高于工資的員工。
Select * from ygb where comm>sal;
4. 找出獎金高于工資60%的員工。
Select * from ygb where comm>sal*0.6;
?
5. 找出部門編號為10中所有經理,和部門編號為20中所有銷售員的詳細資料。
Select * from ygb where (job = ‘經理’?and deptno = ‘10’) or (job = ‘銷售員’?and deptno = ‘20’);
?
Select * from ygb where (job = ‘經理’?and deptno = 10) or (job = ‘銷售員’?and deptno = 20) and (job not in(‘經理’,’銷售員’) and sal >= 20000);
?
Select * from ygb where comm<1000;
8. 查詢名字由三個字組成的員工。
Select * from ygb where ename like ‘___’;
9.查詢2000年入職的員工。
Select * from ygb where hiredate like ‘2000%’;
Select * from ygb where hiredate>=’2000-01-01’?and hiredate<=’2000-12-31’;
10. 查詢所有員工詳細信息,用編號升序排序
Select * from ygb order by mgr asc;
11. 查詢所有員工詳細信息,用工資降序排序,如果工資相同使用入職日期升序排序
Select * from ygb order by mgr desc,hiredate asc;
?
Select * from ygb where ename like ‘周_’;
?
Select * from ygb where ename like ‘張%’;
轉載于:https://www.cnblogs.com/mjwwzy/p/9132010.html
總結
- 上一篇: 要会的123个Python工具!
- 下一篇: 【Luogu3932】浮游大陆的68号岛