简单查询部分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

这篇博客提供了一系列关于SQL简单查询的练习题,重点探讨了months_between函数用于计算两个日期间的月份数,trunc函数截取日期到指定精度,以及add_months函数增加或减少指定月数的功能。通过这些练习,读者可以加深对SQL日期处理的理解。
最低0.47元/天 解锁文章
415

被折叠的 条评论
为什么被折叠?



