oracle基本查询练习
select * from regions;
select * from countries;
select * from locations;
select * from departments;
select * from jobs;
select * from employees;
select * from job_history;
1. 查询工资大于12000的员工姓名和工资
select '姓名:' || first_name || last_name || ',工资:' || salary
from employees
where salary > 12000;
2. 查询员工号为176的员工的姓名和部门号
select first_name, department_id from employees where employee_id = 176;
3. 选择工资不在5000到12000的员工的姓名和工资
select first_name, salary from employees where salary not between 5000 and 12000;
4. 选择雇用时间在1998-02-01到1998-05-01之间的员工姓名,job_id和雇用时间
select 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. 选择在20或50号部门工作的员工姓名和部门号
select first_name, last_name, department_id
from employees
where department_id in (20, 50);
6. 选择在1994年雇用的员工的姓名和雇用时间
select first_name, last_name, hire_date
from employees
where to_char(hire_date, 'yyyy') = 1994;
7. 选择公司中没有管理者的员工姓名及job_id
select first_name, last_name, job_id
from employees
where manager_id is null;
8. 选择公司中有奖金的员工姓名,工资和奖金级别
Select last_name||' '||first_name,salary,commission_pct from employees where commission_pct is not null;
9. 选择员工姓名的第三个字母是a的员工姓名
select first_name, last_name from employees where first_name like '__a%';
10. 选择姓名中有字母a和e的员工姓名
select first_name || ' ' || last_name
from employees
where first_name || last_name like '%a%e'
or last_name || first_name like '%e%a';--为什么firts_name和last_name要倒置写一次??
11. 显示系统时间
select sysdate from dual;
12. 查询员工号,姓名,工资,以及工资提高百分之20%后的结果(new salary)
select * from employees;
select employee_id, first_name||' '||last_name, salary, salary * 1.2 as "new salary" from employees;
13. 将员工的姓名按首字母排序,并写出姓名的长度(length)
select initcap(concat(first_name,last_name)) "name",
length(concat(first_name, last_name)) "length"
from employees
order by substr(concat(first_name, last_name), 1, 1);
14. 查询各员工的姓名,并显示出各员工在公司工作的月份数
select initcap(concat(first_name, last_name)) "name",
round(months_between(sysdate, hire_date)) "month"
from employees
order by substr(concat(first_name, last_name), 1, 1);
15. 查询员工的姓名,以及在公司工作的月份数(worked_month),并按月份数降序排列
select initcap(concat(first_name, last_name)) "name",
round(months_between(sysdate, hire_date)) "worked_month"
from employees
order by "worked_month";
oracle基本查询练习的更多相关文章
- Oracle层次查询
Oracle层次查询的语法如下: 下面根据两道“烧脑”的题具体来体现: 1. 根据时间先后顺序,十二星座的英文名称用逗号串起来为'Aries,Taurus,Gemini,Cancer,Leo,Virg ...
- 【SQL】Oracle分页查询的三种方法
[SQL]Oracle分页查询的三种方法 采用伪列 rownum 查询前10条记录 ? 1 2 3 4 5 6 7 8 9 10 11 [sql] select * from t_user t whe ...
- 关于Oracle中查询的数字值的显示格式需要保留小数点后两位(或者三位,及其他位数)
关于Oracle中查询的数字值的显示格式需要保留小数点后两位(或者三位,及其... 方法一:使用to_char的fm格式,即: to_char(round(data.amount,2),'FM9999 ...
- Oracle参数化查询
Oracle参数化查询默认是根据顺序绑定的 select * from table where name=:p1 and (select id from table2 where name=:p1); ...
- mysql和oracle 分页查询(转)
最近简单的对oracle,mysql,sqlserver2005的数据分页查询作了研究,把各自的查询的语句贴出来供大家学习..... (一). mysql的分页查询 mysql的分页查询是最简单的,借 ...
- Oracle分页查询语句的写法(转)
Oracle分页查询语句的写法(转) 分页查询是我们在使用数据库系统时经常要使用到的,下文对Oracle数据库系统中的分页查询语句作了详细的介绍,供您参考. Oracle分页查询语句使我们最常用的 ...
- Oracle生成查询包括对应于所有数据表记录语句中指定的字段名
应用:已知的字段名,表中的所有数据的查询数据库中包含的所有数据表的字段名 操作方法:指定字段名,用户数据库表,它可以执行以下查询 --Oracle生成查询包括对应于所有数据表记录语句中指定的字段名 d ...
- 各种oracle参数查询语句
各种oracle参数查询语句 1.show parameter:--显示各个系统参数配置 2.select * from v$parameter;--显示各个系统参数配置 2.show paramet ...
- oracle高级查询(实例基于scott用户四张表)
oracle高级查询(实例基于scott用户四张表) 分组查询 多表查询 子查询 综合实例 ====================================================== ...
- oracle分页查询及原理分析(总结)
oracle分页查询及原理分析(总结) oracle分页查询是开发总为常用的语句之一,一般情况下公司框架会提供只需套用,对于增删改查而言,查是其中最为关键也是最为难的一块,其中就有使用率最高的分页查询 ...
随机推荐
- tomcat跨域(亲测可用)
首先下载cors-filter-2.5.jar(版本不要求)和java-property-utils-1.9.1 1.把这两个jar包放在tomcat的lib下. 2.在conf文件夹下找到web.x ...
- Eclipse中使用Spring IOC容器的具体方法
1.通过IOC容器创建对象,并为属性赋值 在IOC容器本身对象创建时(xml文件加载时),会将配置文件中配置好的bean先创建出来,按照xml文件中配置的先后顺序创建 <bean id=&quo ...
- mysql 保存23:59:59 自动加一秒
mysql保存系统传递的时间会诡异的增加一秒钟使用如下工具类: public static Date getEndOfDay(Date date) { Calendar calendarEnd = C ...
- Unity---编辑器扩展---更新中
目录 1.Unity编辑器扩展介绍 2.具体功能 2.1.在菜单栏中添加扩展 2.2.为扩展事件添加快捷键 2.3.Hierarchy,Project视图中右键添加扩展 2.4.使用Selection ...
- 关于IBOutlet的生命周期
在调试程序的时候,发现 IBOutlet的对象在执行 getter时,开始一直想找IBOutlet对象getter方法前被执行的代码,但是一直找不到,于是我就想是不是系统自动给IBOutlet 自动初 ...
- FPGA实战操作(1) -- SDRAM(Verilog实现)
对SDRAM基本概念的介绍以及芯片手册说明,请参考上一篇文章SDRAM操作说明. 1. 说明 如图所示为状态机的简化图示,过程大概可以描述为:SDRAM(IS42S16320D)上电初始化完成后,进入 ...
- Mybatis学习笔记(七) —— 关联查询
一.一对多查询 需求:查询所有订单信息,关联查询下单用户信息. 注意:因为一个订单信息只会是一个人下的订单,所以从查询订单信息出发关联查询用户信息为一对一查询.如果从用户信息出发查询用户下的订单信息则 ...
- visual studio检查运算上溢/下溢的开关位置
[注意] 勾选这个选项会对应用程序的整体性能造成一些影响,但是会更加安全.具体情况根据项目需求来决定.
- echarts图调用多个接口
html: <div id="sentimentMain1" style="width:960px;height:500px;margin:20px auto;&q ...
- java坏境内存不够用 大量占用swap 临时加swap
dd if=/dev/sda of=/tmp/mbr.bin bs=512 count=1 查询2进制文件 file 看文件类型 思路 创建一个大文件作为swap 1.1创建文件 [root ...