当前位置:数据库 > Oracle >>

Oracle表的常用查询实验(四)

Oracle表的常用查询实验(四)
 
Oracle表的常用查询实验(三)
http://www.zzzyk.com/database/201310/249261.html
 
1.找出emp表中的ename第三个字母是A的员工信息
select *from empwhere enamelike'__A%';
2.找出emp表中员工姓名中含有A和的员工姓名
select enamefrom empwhere enamelike'%A%'and enamelike'%N%';
3.找出所有有佣金的员工,列出姓名、工资、佣金,显示结果按工资从小到大,佣金从大到小排序
select sal+nvl(comm,0)as sc,ename,sal,nvl(comm,0)from emp  orderby salasc,scdesc;
4.找出部门号是20的职位类型
select distinct jobfrom emp where deptno=20;
5.显示工资不在1500和2000之间的员工信息:姓名、工资,并按工资从大到小排序
select ename,salfrom empwhere salnot between1500and2000orderby saldesc;
6.把一个职工号所对应的奖学金 ,一个一个读取出来,然后重复的不要
select zgh,to_char(WMSYS.WM_CONCAT(distinct(a.jlqk)))
 from t_jxjagroupbya.zgh;
7.列出至少有一个员工的所有部门
select *from empwhere sal>(select salfrom empwhere ename='YUAN');
8.列出所有员工的姓名及其直接上级的姓名
select e1.ename yuang_name,e2.ename boss_name from scott.emp e1,scott.emp e2 where e1.mgr=e2.empno;
9.列出受雇日期早于其直接上级的所有员工
select t1.enamefrom scott.emp t1,scott.emp t2 where t1.hiredate<t2.hiredateand t1.mgr=t2.empno;
10.列出部门名称和这些部门的员工信息,同事列出那些没有员工的部门
select d.deptno,d.dname,d.loc,e.*from scott.dept d left join scott.empe on d.deptno=e.deptno;
11.列出最低薪资大于1500的各种工作
select job from scott.empe groupbye.jobhavingmin(sal)>1500;
12.列出在部门‘SALES’‘工作的员工的姓名,假定不知道部门编号
selecte.enamefrom scott.empe wheree.deptnoin
(select deptnofrom scott.dept d where d.dname='SALES');
13.列出薪资高于公司平均水平的所有员工
select *from scott.empe where(e.sal+nvl(e.comm,0))>(selectavg(e1.sal+nvl(e1.comm,0))from scott.emp e1);
14.列出与’SCOTT''从事相同工作的所有员工
select enamefrom scott.emp e1where e1.job=(selecte.jobfrom scott.empewhere ename='SCOTT');
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,