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基本查询练习的更多相关文章

  1. Oracle层次查询

    Oracle层次查询的语法如下: 下面根据两道“烧脑”的题具体来体现: 1. 根据时间先后顺序,十二星座的英文名称用逗号串起来为'Aries,Taurus,Gemini,Cancer,Leo,Virg ...

  2. 【SQL】Oracle分页查询的三种方法

    [SQL]Oracle分页查询的三种方法 采用伪列 rownum 查询前10条记录 ? 1 2 3 4 5 6 7 8 9 10 11 [sql] select * from t_user t whe ...

  3. 关于Oracle中查询的数字值的显示格式需要保留小数点后两位(或者三位,及其他位数)

    关于Oracle中查询的数字值的显示格式需要保留小数点后两位(或者三位,及其... 方法一:使用to_char的fm格式,即: to_char(round(data.amount,2),'FM9999 ...

  4. Oracle参数化查询

    Oracle参数化查询默认是根据顺序绑定的 select * from table where name=:p1 and (select id from table2 where name=:p1); ...

  5. mysql和oracle 分页查询(转)

    最近简单的对oracle,mysql,sqlserver2005的数据分页查询作了研究,把各自的查询的语句贴出来供大家学习..... (一). mysql的分页查询 mysql的分页查询是最简单的,借 ...

  6. Oracle分页查询语句的写法(转)

    Oracle分页查询语句的写法(转)   分页查询是我们在使用数据库系统时经常要使用到的,下文对Oracle数据库系统中的分页查询语句作了详细的介绍,供您参考. Oracle分页查询语句使我们最常用的 ...

  7. Oracle生成查询包括对应于所有数据表记录语句中指定的字段名

    应用:已知的字段名,表中的所有数据的查询数据库中包含的所有数据表的字段名 操作方法:指定字段名,用户数据库表,它可以执行以下查询 --Oracle生成查询包括对应于所有数据表记录语句中指定的字段名 d ...

  8. 各种oracle参数查询语句

    各种oracle参数查询语句 1.show parameter:--显示各个系统参数配置 2.select * from v$parameter;--显示各个系统参数配置 2.show paramet ...

  9. oracle高级查询(实例基于scott用户四张表)

    oracle高级查询(实例基于scott用户四张表) 分组查询 多表查询 子查询 综合实例 ====================================================== ...

  10. oracle分页查询及原理分析(总结)

    oracle分页查询及原理分析(总结) oracle分页查询是开发总为常用的语句之一,一般情况下公司框架会提供只需套用,对于增删改查而言,查是其中最为关键也是最为难的一块,其中就有使用率最高的分页查询 ...

随机推荐

  1. P1959 遗址_NOI导刊2009普及(6)

    题意:平面上n个点(坐标$0\le x,y\le 5000,n \le 3000$) 求以其中四个点为顶点的正方形的最大面积 $O(n^2)$枚举两个点作为当前正方形的对角线 那么如何求出另外两个点呢 ...

  2. NOIP2018初赛总结(提高组)(试题+答案+简要解析)

    NOIP2018初赛总结(提高组) 更新完毕(纯手敲),如果有错误请在下面留言 单选题 T1.下列四个不同进制的数中,与其它三项数值上不相等的是 A.\((269)_{16}\) B.\((617)_ ...

  3. 关于NSFetchedResultsController的一些用法

    如何在iPhone等设备持久保存数据,需要用到Core Data,它能帮你快速而有效率的完成数据储存,Core Data 编程经常用到 NSFetchedResultsController这个类,刚开 ...

  4. git 日常使用从入门到真香

    目录 git 日常使用从入门到真香 一.Git简介 二.Git常用命令 三.git操作流程 四.报错处理 git 日常使用从入门到真香 一.Git简介 Git是一个开源的分布式版本控制系统,可以有效. ...

  5. iOS WebDriverAgent 环境搭建

    WebDriverAgent简介 WebDriverAgent是Facebook 在去年的 SeleniumConf 大会上推出了一款新的iOS移动测试框架.当时的推文申明,还只支持模拟器,不过在今年 ...

  6. jq得到总价

    <html><head> <title></title> {load href="/static/js/jquery-1.9.1.min.js ...

  7. 解决ifconfig没有网卡问题

    ifconfig -a root@kali:~# ifup eth0 ifup: unknown interface eth0 vim /etc/network/interfaces #自行添加网卡 ...

  8. eclipse+pydev 安装和配置过程

    安装 PyDev 在安装 PyDev 之前,要保证您已经安装了 Java 1.4 或更高版本.Eclipse 以及 Python.接下来,开始安装 PyDev 插件. 启动 Eclipse,利用 Ec ...

  9. scrapy 组合多个页面的数据一并存储

    暂不重复,请看参考信息 参考: https://segmentfault.com/q/1010000009651745/a-1020000009652641 https://www.jianshu.c ...

  10. Dev Express Report 学习总结(四)Dev Express 动态生成XRTable使用总结

    1. XRTableCell常见属性  XRTableCell xrTableCell = new XRTableCell(); A. 字体及字体大小 xrTableCell.Font = new S ...