一套SQL笔试题


Posted in 面试题 onAugust 14, 2016
1、查找整个职员表的所有内容。
select *
from employees
2、查看雇员名字(last_name)。
select last_name
from employees
3、查看雇员编号、名字和工种。
select last_name,job_id,employee_id
from employees
4、显示所有雇员的姓名、工资并将DEPARTMENT_ID显示为(Department_Id)。
select last_name,salary,DEPARTMENT_ID as Department_Id
from employees

5、查找在60号部门工作的雇员。
select last_name+first_name name,department_id
from employees
where departmet_id=60

6、要求查找职位为SH_CLERK和SA_MAN的雇员姓名(last_name)。
select last_name job_id
from employees
where job_id in (‘sh_clerk’,sa_man’)

7、查找职位不是SH_CLERK和SA_MAN的雇员工种及姓名。将姓名显示为(first_name+last_name命名为”Name”)。
select first_name+last_name Name, job_id
from employees
where job_id not in (‘sh_clerk’,sa_man’)

8、查找哪些雇员的工资在2000到3000之间
select *
from employees
where salary between 2000 and 3000

9、查找哪些雇员的工资不在3000到5000之间
select *
from employees
where salary not between 3000 and 5000

10、查找first_name以D开头,后面仅有三个字母的雇员信息。
select *
from employees
where first_name like ‘D___’ and first_name not like ‘d__ ‘

11、查找last_name以K开头的雇员信息。

select last_name,first_name,department_id
from employees
where last_name like ‘k%’

12、查找名字以字母M开头,以l结尾,并且第三个字母为c的雇员名字(First_name)、工种和所在部门号
select first_name,job_id,department_id
from employees
where first_name like ‘m_c%l’

13、查找哪些雇员的工种名不以SA开头。
select job_id
from employees
where job_id not like ‘sa%’

14、查找没有奖金的雇员信息。
select *
from employees
where commission_pct is null

15、查找有奖金的雇员信息。
select *
from employees
where commission_pct is not null

16、查找30号部门里不是CLERK的雇员信息。

select *
from employees
where department_id=30 and job_id not like ‘%clerk%’

17、查找在30号部门工作或不是CLERK的雇员信息。

select *
from employees
where department_id=30
or job_id not like ‘%clerk%’

查找60号部门且工资大于5000的员工的信息

select *
from employees
where department_id=60
and salary>5000

18、按字母顺序显示雇员的名字(last_name)。

select last_name
from employees
order by last_name

19、按部门号降序显示。

select * from employees order by department_id desc

20、查找工资高于$2000的雇员信息,按部门号和雇员名字排序。

select * from employees where salary>2000 order by department_id,employee_id

21、选择奖金高于5%的雇员信息
SELECT FIRST_NAME, LAST_NAME, COMMISSION_PCT
FROM dbo.EMPLOYEES
WHERE (COMMISSION_PCT > .05)

22 查询年工资高于50000的员工信息
select * from employees where 12*salary>50000

23 查询奖金高于5000的员工姓名

day
1、查出部门地区编号为1700的员工姓名
select first_name,last_name,city,department.location_id
from locations,employees,department
where locations.location_id=department.location_id
and locations.location_id=1700

2、查询工作地区为北京的员工名及工资信息
select first_name,last_name,salary,commission_pct,city
from locations,employees,departments
where departments.location_id=locations.location_id
and departments.department_id = employees.department_id
and departments.location_id=1700

3、查询薪水标准为B类的员工名称和员工薪水以及工资类别名称
select last_name,first_name,salary,commission_pct,gra
from departments d,employees e,job_grades j
where e.salary between j.lowest and j.highest
and j.gra=’b’
and d.department_id=e.department_id

4、查询出主管Raphaely管理的员工和薪水信息
select a.last_name+a.first_name as name, a.salary,a.commission_pct,b.last_name
from employees a,employees b
where a.department_id=b.department_id
and a.last_name like ‘%raphaely%’

5、查出雇员所在的部门,并将没有雇员的部门的记录也显示出来。
select e.last_name+e.first_name as name,d.department_id
from departments d
left outer join employees e
on (e.department_id=d.department_id)

6、查询出没有分配部门的员工信息

select e.last_name+e.first_name as name,e.department_id
from departments d
left outer join employees e
on (e.department_id=d.department_id)
where d.department_id is null

7、计算每个部门的平均工资和工资总和
select department_id,sum (salary) sum,avg (salary) avg
from employees
group by department_id

8、查询每个部门的每个工种的雇员数
select count(*)num,department_id,job_id
from employees
group by department_id,job_id

9、请算出employee表中总雇员数量
select count(*)
from employee

10.请算出employee表中所有雇员的平均工资

select avg(salary)
from employee

11.请查询出employee表中的最低工资

select min(salary)
from employee

12.请查询出employee表中最高工资
select max(salary)
from employee

13、请计算出每个部门的平均工资、最高工资和最低工资
select max(salary) max,min(salary) min,avg(salary) avg,department_id
from employee
group by department_id

14、查询按部门名称分组工资总和大于4200的部门名称、工资和
select department_name,sum(salary)
from employees e,departments d
where e.department_id=d.department_id
group by department_name
having sum(salary)>4200
test001

1.请查询出employee表中最低工资的雇员

select last_name
from employee
where salary=(select min(salary) from employee)

2.请查询出employee表中最高工资的雇员

select last_name
from employee
where salary=(select max(salary) from employee)

3、查询工资高于105号雇员的last_name,并且工种与他相同的雇员情况。

select last_name,job_id,salary
from employees
where salary>(select salary from employees where employee_id=’105′)
and job_id=(select job_id from employees where employee_id=’105′)

4、查询工资高于或等于30号部门工资最高额的雇员。
select last_name,salary
from employees
where salary>=(select max(salary) from employees where department_id=30)

5 查询工资在1000到5000之间的雇员所在部门的所有人员的信息。

select *
from employees
where department_id in
(select department_id from employees where salary between 1000 and 5000)

6 查找工资高于60号部门所有员工的人员信息。显示其员工编号,last_name和工资。

select last_name,employee_id,salary
from employees
where salary>
(select max(salary) from employees where department_id=60)

7 将114号雇员的工种和部门号改为102号雇员的工种和部门号。

8、将所有与106号雇员相同工种的职工的部门号改成106号雇员所在的部门。

9、查询工种不为SH_CLERK,并且工资小于其中任何一个SH_CLERK的雇员信息。

Tags in this post...

面试题 相关文章推荐
PHP如何去执行一个SQL语句
Mar 05 面试题
PHP两种查询函数array/row的区别
Jun 03 面试题
Tomcat中怎么使用log4j输出所有的log
Jul 07 面试题
SQL Server面试题
Oct 17 面试题
不用游标的SQL语句有哪些
Sep 07 面试题
索引覆盖(Index Covering)查询含义
Feb 18 面试题
广州品高软件.net笔面试题目
Apr 18 面试题
什么是命名空间(NameSpace)
Nov 24 面试题
什么是符号链接,什么是硬链接?符号链接与硬链接的区别是什么?
May 03 面试题
比较一下entity bean和session bean
Dec 27 面试题
EJB需直接实现它的业务接口或Home接口吗,请简述理由
Nov 23 面试题
如何写一个自定义标签
Dec 28 面试题
SQL里面如何插入自动增长序列号字段
Mar 29 #面试题
几个数据库方面的面试题
Jul 01 #面试题
不用游标的SQL语句有哪些
Sep 07 #面试题
如何查找和删除数据库中的重复数据
Nov 05 #面试题
如何高效率的查找一个月以内的数据
Apr 15 #面试题
数据库方面面试题
Apr 22 #面试题
使用索引(Index)有哪些需要考虑的因素
Oct 19 #面试题
You might like
我的论坛源代码(五)
2006/10/09 PHP
开启CURL扩展,让服务器支持PHP curl函数(远程采集)
2011/03/19 PHP
php对数组排序的简单实例
2013/12/25 PHP
php数组键值用法实例分析
2015/02/27 PHP
通过PHP自带的服务器来查看正则匹配结果的方法
2015/12/24 PHP
JavaScript语句可以不以;结尾的烦恼
2007/03/08 Javascript
JavaScript 函数惰性载入的实现及其优点介绍
2013/08/12 Javascript
Javascript Ajax异步读取RSS文档具体实现
2013/12/12 Javascript
Jquery实现弹性滑块滑动选择数值插件
2015/08/08 Javascript
jQuery实现两款有动画功能的导航菜单代码
2015/09/16 Javascript
JS实现显示带倒影的图片横排居中放大展示特效实例【测试可用】
2016/08/23 Javascript
JS判断浏览器是否安装flash插件的简单方法
2016/09/13 Javascript
使用AngularJS编写多选按钮选中时触发指定方法的指令代码详解
2017/07/24 Javascript
解决低版本的浏览器不支持es6的import问题
2018/03/09 Javascript
Vue自定义过滤器格式化数字三位加一逗号实现代码
2018/03/23 Javascript
VueJS 组件参数名命名与组件属性转化问题
2018/12/03 Javascript
JavaScript中.min.js和.js文件的区别讲解
2019/02/13 Javascript
vue 判断两个时间插件结束时间必选大于开始时间的代码
2020/11/04 Javascript
[42:52]Optic vs Serenity 2018国际邀请赛淘汰赛BO3 第二场 8.22
2018/08/23 DOTA
Python中pip安装非PyPI官网第三方库的方法
2015/06/02 Python
Ubuntu 下 vim 搭建python 环境 配置
2017/06/12 Python
python中itertools模块zip_longest函数详解
2018/06/12 Python
Golang GBK转UTF-8的例子
2019/08/26 Python
python实现图像拼接功能
2020/03/23 Python
CSS3中Transform动画属性用法详解
2016/07/04 HTML / CSS
Europcar英国:英国汽车和货车租赁
2017/01/21 全球购物
在印度上传处方,在线订购药品:Medlife
2019/03/28 全球购物
英国设计师珠宝网站:Joshua James Jewellery
2020/03/01 全球购物
Set里的元素是不能重复的,那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别?
2014/07/27 面试题
办理信用卡工作证明
2014/01/11 职场文书
《会走路的树》教后反思
2014/04/19 职场文书
投标服务承诺书
2014/05/28 职场文书
校园文明标语
2014/06/13 职场文书
交通工程专业推荐信
2014/09/06 职场文书
教师批评与自我批评(群众路线)
2014/10/15 职场文书
浅谈JS的二进制家族
2021/05/09 Javascript