sql语句复习题
更新时间:2024-02-29 21:04:01 阅读量: 综合文库 文档下载
- sQl语句推荐度:
- 相关推荐
--1.查询emp表中的所有信息
SELECT*FROMscott.emp;
--2.显示emp表的员工姓名和工资
SELECTscott.emp.ename,scott.emp.salFROMscott.emp;
--3查询emp表中部门编号为20的并且sal大于3000的所有员工信息
SELECT*FROMscott.empWHEREempno=20ANDsal>3000;
--4查询emp表中部门编号为20的或者sal大于3000的所有员工信息
SELECT*FROMscott.empWHEREempno=20ANDsal>3000;
--5使用bettwen and 查询工资在2000到4000之间员工信息
SELECT*FROMscott.empWHEREsalBETWEEN2000AND4000;
--6使用in 查询部门编号10 20的所有员工
SELECT*FROMscott.empWHEREdeptnoIN(10,20);
7、使用like查询所有名字中包括 W的员工信息 select * from scott.emp where enamel like '%w%'
8、使用like查询所有员工名字中第二子字母为W的员工信息 select * from scott.emp where enamel like '_w%'
9、查询所有员工信息并按照部门编号和工资进行排序
select* from scott.emp,scott.dept when scott.emp.empno=scott.dept.deptno and order by sal; 10、显示员工工资上浮20%的结果。
selectscott.emp.salscott.emp.sal*(1+20%) from scott.emp;
11、显示EMP表的员工姓名以及工资和奖金的和。
selectempno,ename, sal, comm, (sal + comm) * 12 from emp;
selectempno, ename, sal, comm, nvl(comm, 0), (sal + nvl(comm, 0)) * 12 income from emp 12、显示DEPT表的内容,使用别名将表头转换成中文显示。
select scott.dept.deptno as \号码\13、查询员工姓名和工资,并按工资从小到大排序。
selectscott.emp.ename,scott.emp.sal from scott.emp order by sal;
14、查询员工姓名和雇佣日期,并按雇佣日期排序,后雇佣的先显示。 selectscott.emp.ename,scott.emp.hiredate from scott.emp order by hiredate;
15、查询员工信息,先按部门编号从小到大排序,再按雇佣时间的先后排序。 select* from scott.emp order by empno and order by hiredate 16、按工资和工作月份的乘积排序(倒序)。
SELECT empno, ename, sal*Months_between(sysdate,hiredate) AS total FROM emp ORDER BY total
17、显示职务为“SALESMAN”的员工的姓名、职务和工资。
selectscott.emp.enamescott.emp.sal,scoott.emp.job where job = \18、显示工资大于等于3000的员工姓名、职务和工资。
selectscott.emp.enamescott.emp.sal,scoott.emp.job where sal>3000; 19、显示1982年以后雇佣的员工姓名和雇佣时间。
selectscott.emp.ename,scott.emp.hiredate where hiredate<1982; 20、显示部门编号为10的员工姓名和雇佣时间
selectscott.emp.ename,scott.emp.hiredate where empno=10;
21、显示工资在1000~2000之间(不包括1000和2000)的员工信息。 select *from scott.emp where sal between 1000 and 2000; 22、显示部门10中工资大于1500的员工。
select* from scott.emp where deptno=10 and sal>1500; 23、显示职务为CLERK或MANAGER的员工信息。
select * from scott.emp where job = clerk or job = manager;
24、显示部门10以外的其他部门的员工。
25、显示部门10和部门20中工资小于1500的员工。
select* from scott.emp where deptno = 20 and deptno = 20 and sal<1500; 26、显示名称以“W”开头的员工,并将姓名转换成小写。 select * from scott.emp where ename like 'w%' and lower(ename);
27、显示员工姓名中包含“S”的员工姓名及姓名长度。
selectscott.emp.ename,length(ename) from scott.emp where instr(ename,'S',1,1)>0;
28、显示部门表中部门和所在城市列表,中间以下划线“_”连接,城市名转换成以小写。 selectscott.dept.loc,scott.dept.deptno from scott,dept where substr('loc',1,1);2 select dname||'_'||initcap(loc) from dept; DNAME||'_'||INITCAP(LOC) 29、显示系统的当前日期 selectsysdate from dual;
30、假定当前的系统日期是2013年11月13日,求再过1000天的日期。 select sysdat+1000 as \
31、假定当前的系统日期是2013年11月13日,显示部门10员工的雇佣天数。 selectscott.emp.enam round(sysdate-hiredate)DAYS from scott.emp where empno =10; 32、显示员工姓名和雇佣的星期数
selectempno, ename, round((sysdate - hiredate) / 7) from emp 33、显示从本年1月1日开始到现在经过的天数。
select round(sysdate-round(sysdate,'year')) as 天数 from dual; 34、查询所有员工的奖金,如果奖金没有,用0来替代 selectempno,nvl(comm,0) comm, from scott.emp;
正在阅读:
sql语句复习题02-29
关于朱自清的散文特色03-21
舞台机械招标文件第三册(货物需求一览表和技术规格部分)04-06
2015版高考化学考点分类汇编(近3年真题+模拟)专题八 化学反应速率与化学平衡10-07
钣金、焊接质量检验标准-执行09-20
江苏省南通市2018年中考英语网上适应性练习试卷(含答案)04-21
电子商务实验指导书201006-19
关于北京市开展股权投资基金及其管理企业做好利用外资工作试点的暂行办法12-04
行为习惯主题班会05-30
第二章,可靠性的概念07-21
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 复习题
- 语句
- sql
- 05-06学期药剂学期末考试考试题.二
- 政策执行视角下的广东省援外医疗队派遣难问题研究
- 2019-2020年高中语文必修四2.4《雨霖铃》word教案
- 10古诗晨诵教案
- 教育类核心期刊投稿电子地址
- 南开大学 思修 论述题
- 推荐人台项目可行性研究报告(技术工艺+设备选型+财务概算+厂区
- 2011-2013北京高考模拟真题汇编 - - 电解质溶液
- 微生物鉴定中常用的生理生化试验的观察 - 图文
- 制存梁台座CFG桩作业指导书
- 氧气站系统安全操作规程
- 大国崛起对中华民族复兴的启示
- 国际经济法案例(附答案)
- 数电课程设计任务书
- 利用外部性理论分析环境污染及其治理
- 《毕业实习》教学大纲 - 图文
- 三年级下册生命与健康常识集体备课教案
- 给学生一份真诚的爱(王淑霞)
- 锅炉检修工试题集
- Auto CAD 2014快捷键及指令