简单sql部分强化练习题
简单查询部分sql练习题
-- 选择部门30中的全部职工
select * from emp where deptno = 30; -- 列出全部业务员(CLERK)的姓名,编号,和部门编号
select e.ename, e.empno, e.deptno from emp e where e.job = 'CLERK'; -- 找出奖金高于薪金的员工
select * from emp where comm > sal; -- 找出奖金高于薪金的60%的员工
select * from emp where comm > sal * 0.6; -- 找出部门10中全部经理(MANAGER)和部门20中全部业务员(CLERK)的具体资料
select * from emp e
where e.deptno = 10 and e.job = 'MANAGER'
or e.deptno = 20 and e.job = 'CLERK'; select * from emp e
where (e.deptno = 10 and e.job = 'MANAGER')
or (e.deptno = 20 and e.job = 'CLERK'); select * from emp e where e.deptno = 10 and e.job = 'MANAGER'
union
select * from emp e where e.deptno = 20 and e.job = 'CLERK'; -- 找出部门10中全部经理(MANAGER),部门20中全部业务员(CLERK),既不是经理又不是业务员但其薪水大于等于2000的全部员工的具体资料
select * from emp e where e.deptno = 10 and e.job = 'MANAGER'
union
select * from emp e where e.deptno = 20 and e.job = 'CLERK'
union
select * from emp e where e.sal > 2000 and e.job not in('MANAGER', 'CLERK'); -- 找出收取奖金的员工的不同工作
select distinct e.job from emp e; -- 找出不收取奖金或收取的奖金低于100的员工
select * from emp e where e.comm is null or e.comm < 100; -- 找出各月倒数第3天受雇的全部员工
select * from emp e where e.hiredate between last_day(hiredate)-3 and last_day(hiredate); -- 找出早于30年前受雇的员工
select * from emp e where (sysdate - e.hiredate)/365 > 30; -- 以首字母大写的方式显示全部员工的姓名
select initcap(ename) from emp; -- 显示正好为5个字符的员工姓名
select * from emp where length(ename) = 5; -- 显示不带有”R”的员工姓名
select * from emp where ename not like '%K%'; -- 显示全部员工姓名的前三个字符
select substr(ename, 0, 3) from emp; -- 显示全部员工的姓名,并用’a’替换全部’A’
select replace(ename, 'A', 'a') from emp; -- 显示满30年服务年限的员工姓名和受雇日期
select * from emp where (sysdate - hiredate)/365 > 30; -- 显示员工的具体资料,按姓名由大到小排序
select * from emp order by ename desc; -- 显示员工的姓名和受雇日期。依据其服务年限,将最老的员工排在最前面
select ename, hiredate from emp order by hiredate asc; -- 显示全部员工的姓名,工作和薪金,按工作降序排列,若工作同样则按薪金升序排序
select ename, job, sal from emp order by job desc, sal asc;
select ename, job, sal from emp order by 2 desc, 3; -- 显示全部员工的姓名,增加公司的年份和月份,按受雇日期所在的月排序。若月份同样。则将最早年份排在最前面
select ename, to_number(to_char(hiredate, 'yyyy')) Year, to_number(to_char(hiredate, 'mm')) from emp order by 3 desc, 2 asc; -- 显示一个月为30天的情况所员工的日薪金。忽略余数
select round(sal/30) 日薪 from emp; -- 找出在(不论什么年份)2月受聘的全部员工
select * from emp where to_number(to_char(hiredate, 'mm'))= 2; -- 对每一个员工,显示其增加公司的天数
select ename, round(sysdate - hiredate) Days from emp; -- 显示姓名中任何位置包括“A”的全部员工姓名
select * from emp where upper(ename) like '%A%'; -- 以年月日方式显示全部员工的服务年限
select ename, hiredate,
trunc(months_between(sysdate, hiredate) /12) year ,
trunc(mod(months_between(sysdate, hiredate) , 12 ) ) months ,
trunc(sysdate - add_months(hiredate,months_between(sysdate, hiredate))) day
from emp ;
简单sql部分强化练习题的更多相关文章
- 基于简单sql语句的sql解析原理及在大数据中的应用
基于简单sql语句的sql解析原理及在大数据中的应用 李万鸿 老百姓呼吁打土豪分田地.共同富裕,总有一天会实现. 全面了解你所不知道的外星人和宇宙真想:http://pan.baidu.com/s/1 ...
- 从简单Sql探索优化之道
从简单Sql探索优化之道 梁敬彬 2016-03-17 09:39:41 本文需要优化的语句是select count(*) from t,这简单的统计语句一出,估计不少人纳闷了,能有啥优化空间,还优 ...
- [数据库]简单SQL语句总结
1.在查询结果中显示列名:a.用as关键字:select name as '姓名' from students order by ageb.直接表示:select name '姓名' from ...
- 简单SQL注入试探、二
DVWA——简单SQL注入小记 今天我们来记录简单的盲注过程 简单的SQL injection(blind) Level:low 登陆后选择SQL Injection(Blind) 能看到这样的界面 ...
- 简单SQL注入试探、一
DVWA——简单SQL注入小记 前不久刚开始接触SQL注入,今天来记录一些最近的一些收获和一些SQL注入方面的知识. 主要是基于DVWA这个开源的平台来进行练习. 废话不多说开始解题. 从简单的SQL ...
- 简单sql字段解析器实现参考
用例:有一段sql语句,我们需要从中截取出所有字段部分,以便进行后续的类型推断,请给出此解析方法. 想来很简单吧,因为 sql 中的字段列表,使用方式有限,比如 a as b, a, a b... 1 ...
- 简单Sql语句统计每年每个月的数据,每个月为数据的每列,简单SQL练习
有一张表,数据如下 请写出结果为以下的SQL语句. 在mysql中创建表 CREATE TABLE `aa` ( `id` int(10) NOT NULL AUTO_INCREMENT COMME ...
- Flask关于请求表单的粗浅应用及理解+简单SQL语句温习
1.请求表单 请求表单的知识点是flask数据请求中很小的一部分,首先要了解一下GET和POST请求:http://www.w3school.com.cn/tags/html_ref_httpmeth ...
- Oracle ORDS的简单SQL配置模板
1. 先加上简单的SQL配置模板. DECLARE PRAGMA AUTONOMOUS_TRANSACTION; BEGIN ORDS.ENABLE_SCHEMA(p_enabled => TR ...
随机推荐
- Cts框架解析(1)-windows下cts配置
环境搭建 下载 cts工具的下载地址:http://source.android.com/compatibility/downloads.html windows选择Android4.4 R3 Com ...
- 7. Spring Boot 启动加载数据 CommandLineRunner
转自:https://blog.csdn.net/catoop/article/details/50501710
- 10.static_extern
另一个文件声明 #include <iostream> using namespace std; ; void show() { cout << " << ...
- vue <input type="file">上传图片、预览、删除
使用原生<input type="file">上传图片.预览.删除:multiple实现可上传多张 参数名 类型 说明 fileTypes Array 文件类型, 默认 ...
- SpringMVC学习总结(2)——SpringMVC返回json配置
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" c ...
- 13. 关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
在一切准备就绪之后,测试test,却出现了org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) ...
- LeetCode Algorithm 04_Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted ...
- 每天五个java相关面试题(3)
1. Servlet的生命周期是什么? 答: 第一次请求: 构造方法->init() -> service() -> doGet()/doPost() 以后的请求:service() ...
- PatentTips - Handling shared interrupts in bios under a virtualization technology environment
BACKGROUND This relates to the operation of software under a virtualization technology (VT) environm ...
- [Nuxt] Use Vuex Actions to Delete Data from APIs in Nuxt and Vue.js
You'll begin to notice as you build out your actions in Vuex, many of them will look quite similar. ...