切换到 oracle的 hr用户下面练习

 

1. 查询工资大于12000的员工姓名和工资

select initcap(concat(last_name,first_name)) "姓名",

salary "工资" from employees where salary>12000;

2. 查询员工号为176的员工的姓名和部门号

select initcap(concat(last_name,first_name)) "姓名",

department_id "部门号" from employees where employee_id=176;

3. 选择工资不在500012000的员工的姓名和工资

select initcap(concat(last_name,first_name)) "姓名",

salary "工资" from employees where salary not between

5000 and 12000;

4. 选择雇用时间在1998-02-011998-05-01之间的员工姓名,job_id和雇用时间

select initcap(concat(last_name,first_name)) "姓名",

job_id,hire_date from employees where hire_date between

to_date('1998-02-01','YYYY-MM-DD') and to_date('1998-05-01','YYYY-MM-DD');

5. 选择在2050号部门工作的员工姓名和部门号

select initcap(concat(last_name,first_name)) "姓名",

department_id from employees where department_id in (20,50);

6. 选择在1994年雇用的员工的姓名和雇用时间

select initcap(concat(last_name,first_name)) "姓名",

hire_date from employees where

hire_date between to_date('1994-1-1','YYYY-MM-DD') and to_date('1994-12-31','YYYY-MM-DD');

7. 选择公司中没有管理者的员工姓名及job_id

select initcap(concat(last_name,first_name)) "姓名",

job_id from employees where nvl(manager_id,0)=0;

8. 选择公司中有奖金的员工姓名,工资和奖金级别

select initcap(concat(last_name,first_name)) "姓名",

job_id from employees where nvl(manager_id,0)=0;

9. 选择员工姓名的第三个字母是a的员工姓名

select initcap(concat(last_name,first_name)) "姓名",

From emloyees

Where last_name like '__a%';

10. 选择姓名中有字母ae的员工姓名

select initcap(concat(last_name,first_name)) "姓名",

From emloyees

Where concat(last_name,first_name) like '%a%' and concat(last_name,first_name) like '%e%';

11. 显示系统时间

Select current_timestamp from dual;

12. 查询员工号,姓名,工资,以及工资提高百分之20%后的结果(new salary

Select first_name,salary*0.2,employee_id from employees;

13. 将员工的姓名按首字母排序,并写出姓名的长度(length

Select frist_name,length(first_name) from employees order by substr(first_name,1,1);

14. 查询各员工的姓名,并显示出各员工在公司工作的月份数

//为什么会出小数?

Select initcap(concat(last_name,first_name)) "姓名",months_between(sysdate,hire_date)

"工作月数" From employees;

15. 查询员工的姓名,以及在公司工作的月份数(worked_month),并按月份数降序排列

Select initcap(concat(last_name,first_name)) "姓名",months_between(sysdate,hire_date)

"工作月数" From employees order by months_between(sysdate,hire_date) desc;

1. 做一个查询,产生下面的结果

<last_name> earns <salary> monthly but wants <salary*3>

Dream Salary

King earns $24000 monthly but wants $72000

Select last_name||' earns '||to_char(salary,'$99999')||' monthly but wants '||to_char(salary*3,'$99999') as "Dream Salary" from employees;

2. 使用decode函数,按照下面的条件:

job grade

AD_PRES A

ST_MAN B

IT_PROG C

SA_REP D

ST_CLERK E

Others F

产生下面的结果

Select last_name,job_id,decode(job_id,

'AD_PRES','A',

'ST_MAN','B',

'IT_PROG','C',

'SA_REP','D',

'ST_CLERK','E',

'F'

) as "grade" from employees;

Last_name

Job_id

Grade

king

AD_PRES

A

3. 将第17题的查询用case函数再写一遍。

Select last_name,job_id,

case job_id

when 'AD_PRES' then 'A'

when 'ST_MAN' then 'B'

when 'IT_PROG' then 'C'

when 'SA_REP' then 'D'

when 'ST_CLERK' then 'E'

Else 'F' end "Grage" from employees;

下面的后边学过之后写:

4. 查询公司员工工资的最大值,最小值,平均值,总和

Select max(salary) "最大值",min(salary) "最小值",avg(salary) "平均值",sum(salary) "总和" from employees;

5. 查询各job_id的员工工资的最大值,最小值,平均值,总和

Select max(salary) "最大值",min(salary) "最小值",avg(salary) "平均值",sum(salary) "总和" from employees group by job_id;

6. 选择具有各个job_id的员工人数

Select count(*),job_id from employees group by job_id;

7. 查询员工最高工资和最低工资的差距(DIFFERENCE

Select max(salary)-min(salary) as "DIFFERENCE" from employees;

8. 查询各个管理者手下员工的最低工资,其中最低工资不能低于6000,没有管理者的员工不计算在内

Select min(salary) from employees group by manager_id having min(salary)>=6000 and manager_id is not null;

9. 查询所有部门的名字,location_id,员工数量和工资平均值

Select department_name,location_id,count(e.job_id),avg(e.salary) from departments d,employees e where d.department_id=e.department_id group by department_name,location

转载于:https://www.cnblogs.com/zhangguoliang521/archive/2013/04/02/3057472.html

内容概要:本文档是一份关于大数据开发的笔试题目集合,涵盖了多个计算机科学领域的知识点。主要内容包括:数组排序算法的应用,如给出了一段不完整的冒泡排序代码示例;二叉树的基本操作,包括普通二叉树的遍历方式(先序遍历),以及针对大规模数据(如一亿个节点)时避免服务器崩溃的优化策略——采用分布式计算思想将单棵大树拆分为多棵小树并行处理;人力资源系统的数据库设计方案,涉及到了员工信息存储所需的字段(如ID、姓名、工资、上级ID、层级)、展示公司内部架构的SQL语句(利用CTE公共表达式或者PL/SQL中的特定语法来构建递归查询),还有统计某个管理者所辖人数的方法论。 适合人群:正在准备大数据相关岗位面试的技术人员,尤其是那些希望加深对数据结构、算法以及数据库设计等方面理解的人群。 使用场景及目标:①帮助求职者熟悉常见的编程技巧与理论知识,提高解决实际问题的能力;②为从事企业级应用开发工作的程序员提供参考案例,以便更好地理解和实施复杂的数据管理和业务逻辑建模任务。 阅读建议:由于文档中包含了多种类型的题目,建议读者按照自己的薄弱环节选择重点复习的内容。对于排序算法部分,应该注意理解各种经典算法的工作机制及其优缺点;对于二叉树的问题,则要掌握不同遍历顺序的特点,并思考如何应对海量数据带来的挑战;最后,在研究HR系统相关的数据库设计时,除了要学会正确地创建表格外,还应学会运用适当的SQL语句来进行高效的数据检索和分析。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值