一套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...

面试题 相关文章推荐
面向对象编程的优势是什么
Dec 17 面试题
请编写一个 C 函数,该函数在给定的内存区域搜索给定的字符,并返回该字符所在位置索引值
Sep 15 面试题
编写类String的构造函数、析构函数和赋值函数
May 29 面试题
我看到了用指针调用函数的不同语法形式
Jul 16 面试题
iostream与iostream.h的区别
Jan 16 面试题
杭州龙健科技笔试题.net部分笔试题
Jan 24 面试题
请解释流与文件有什么不同
Jul 29 面试题
以太网Ethernet IEEE802.3
Aug 05 面试题
什么是静态路由,其特点是什么?什么是动态路由,其特点是什么?
Jul 26 面试题
局域网标准
Sep 10 面试题
下面代码从性能上考虑,有什么问题
Apr 03 面试题
一道Delphi上机题
Jun 04 面试题
SQL里面如何插入自动增长序列号字段
Mar 29 #面试题
几个数据库方面的面试题
Jul 01 #面试题
不用游标的SQL语句有哪些
Sep 07 #面试题
如何查找和删除数据库中的重复数据
Nov 05 #面试题
如何高效率的查找一个月以内的数据
Apr 15 #面试题
数据库方面面试题
Apr 22 #面试题
使用索引(Index)有哪些需要考虑的因素
Oct 19 #面试题
You might like
header导出Excel应用示例
2014/01/24 PHP
为PHP安装imagick时出现Cannot locate header file MagickWand.h错误的解决方法
2014/11/03 PHP
php中实现获取随机数组列表的自定义函数
2015/04/02 PHP
ThinkPHP和UCenter接口冲突的解决方法
2016/07/25 PHP
CentOS 上搭建 PHP7 开发测试环境
2017/02/26 PHP
基于逻辑运算的简单权限系统(实现) JS 版
2007/03/24 Javascript
利用腾讯的ip地址库做ip物理地址定位
2010/07/24 Javascript
JS实现倒计时和文字滚动的效果实例
2014/10/29 Javascript
JS组件Bootstrap Table布局详解
2016/05/27 Javascript
第一次接触神奇的Bootstrap表单
2016/07/27 Javascript
JS+html5制作简单音乐播放器
2020/09/13 Javascript
Vue2.0父组件与子组件之间的事件发射与接收实例代码
2017/09/19 Javascript
原生JavaScript实现Ajax异步请求
2017/11/19 Javascript
JS删除String里某个字符的方法
2021/01/06 Javascript
element-ui中按需引入的实现
2019/12/25 Javascript
jQuery实现轮播图效果demo
2020/01/11 jQuery
Python实现partial改变方法默认参数
2014/08/18 Python
Python两个整数相除得到浮点数值的方法
2015/03/18 Python
python登录pop3邮件服务器接收邮件的方法
2015/04/30 Python
python3 判断列表是一个空列表的方法
2018/05/04 Python
用PyInstaller把Python代码打包成单个独立的exe可执行文件
2018/05/26 Python
Python嵌套式数据结构实例浅析
2019/03/05 Python
python+pyqt5实现图片批量缩放工具
2019/03/18 Python
Python环境Pillow( PIL )图像处理工具使用解析
2019/09/12 Python
python 异步async库的使用说明
2020/05/04 Python
idealfit英国:世界领先的女性健身用品和运动衣物品牌
2017/11/25 全球购物
英国第一家领先的在线处方眼镜零售商:Glasses Direct
2018/02/23 全球购物
澳洲国民品牌乡村路折扣店:Country Road & Trenery Outlet
2018/04/19 全球购物
Kangol帽子官网:坎戈尔袋鼠
2018/09/26 全球购物
英国Flybe航空官网:欧洲最大的独立支线廉价航空公司
2019/07/15 全球购物
Clarks鞋澳大利亚官方网站:Clarks Australia
2019/12/25 全球购物
教育学专业实习生的自我鉴定
2013/11/26 职场文书
行政申诉状范文
2015/05/20 职场文书
扩展多台相同的Web服务器
2021/04/01 Servers
彻底理解golang中什么是nil
2021/04/29 Golang
MySQL GRANT用户授权的实现
2021/06/18 MySQL