mysql创表的工种_mysql测试数据库employees一些sql语句
一套SQL筆試題
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的雇員信息。
總結
以上是生活随笔為你收集整理的mysql创表的工种_mysql测试数据库employees一些sql语句的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 10款js图片代码_图片滚动代码_图片切
- 下一篇: struts2接受webupload框架