PLSQL 的简单命令之二
--1. 查询工资大于12000的员工姓名和工资
select first_name,last_name,salary from employees where salary > 12000 --2. 查询员工号为176的员工的姓名和部门号
select first_name,last_name,department_id from employees where job_id = '' --3. 选择工资不在5000到12000的员工的姓名和工资
select first_name,last_name,salary from employees where salary < 5000 and salary > 12000 --4. 选择雇用时间在1998-02-01到1998-05-01之间的员工姓名,job_id和雇用时间
select first_name,last_name,job_id,hire_date from employees where
to_char(hire_date,'yyyy-mm-dd')>='1998-02-01' and to_char(hire_date,'yyyy-mm-dd')<='1998-05-01'; --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')='' --7. 选择公司中没有管理者的员工姓名及job_id
select first_name,last_name,job_id from employees where manager_id is null; --8. 选择公司中有奖金的员工姓名,工资和奖金级别
select first_name,last_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%' or last_name like '__a%'; --10. 选择姓名中有字母a和e的员工姓名
select first_name,last_name from employees where lower(first_name) like '%a%'and
lower(first_name) like '%e%' or lower(last_name)like '%a%' and lower(last_name)like '%e%'; --单行函数
--1. 显示系统时间(注:日期+时间)
select sysdate from dual --2. 查询员工号,姓名,工资,以及工资提高百分之20%后的结果(new salary)
select employee_id,first_name,last_name,salary,salary*1.2 as "NEW SALARY" from employees --3. 将员工的姓名按首字母排序,并写出姓名的长度(length)
select substr(first_name,1,1) as FIRSTWORD, length(first_name) as "LENGTH" from employees
order by substr(first_name,1,1) asc --4. 查询各员工的姓名,并显示出各员工在公司工作的月份数(worked_month)。
select first_name,last_name,round( months_between(sysdate,hire_date))WORKED_MONTHS from employees --5. 查询员工的姓名,以及在公司工作的月份数(worked_month),并按月份数降序排列
select first_name,last_name,round( months_between(sysdate,hire_date))WORKED_MONTHS from employees
order by WORKED_MONTHS desc
/*6. 做一个查询,产生下面的结果
<last_name> earns <salary> monthly but wants <salary*3>
Dream Salary
King earns $24000 monthly but wants $72000
*/
select last_name || ' earns '||salary||' monthly but wants '||salary*3 as "A GREAT DREAM" from employees /*7. 使用decode函数,按照下面的条件:
job grade
AD_PRES A
ST_MAN B
IT_PROG C
SA_REP D
ST_CLERK E
产生下面的结果
Last_name Job_id Grade
king AD_PRES A
*/
select Last_name||' '||job_id||' '||decode(job_id,'AD_PRES','A',
'ST_MAN','B',
'IT_PROG','C',
'SA_REP','D',
'ST_CLERK','E')
||' king AD_PRES A' as SOMEWORDS from employees --8. 将第7题的查询用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 ' '
end
||' king AD_PRES A' as SOMEWORDS from employees
PLSQL 的简单命令之二的更多相关文章
- PLSQL 的简单命令之三
-- 查找两个表中ID相等的 select a.id, a.name,b.math from stu a,scores b where a.id = b.id -- 右外连接 select b.id, ...
- PLSQL 的简单命令之五
--1. 查询和Zlotkey相同部门的员工姓名和雇用日期 select a.last_name,a.hire_date ,b.department_name from employees a,dep ...
- PLSQL 的简单命令之四
-- 子查询 -- in 等于表中的任意一个 select * from Stu where id in (select id from scores) -- 和子查询返回结果中的某一个值比较成立即可 ...
- Apache 的搭建及vim的简单命令
一. vim 简单命令 pwd 当前路径 ls 当前路径所有目录 cd 目录地址 跳转到指定目录 /xxx 查找xxx x 删除当前字符 n 执行上一次查找 二.为什么使用apa ...
- 从零单排Linux – 1 – 简单命令
从零单排Linux – 1 – 简单命令 Posted in: Linux 从零单排Linux – 1 一.Linux的简单命令: 1.忘记root密码: 读秒时按任意键进入 – e – ↓选择第二个 ...
- Kafka学习(一)配置及简单命令使用
一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,当中涉及到的相关概念例如以下: Kafka中传递的内容称为message(消息),message 是通过topic ...
- Kafka配置及简单命令使用
一. Kafka中的相关概念的介绍 Kafka是一个scala实现的分布式消息中间件,其中涉及到的相关概念如下: Kafka中传递的内容称为message(消息),message 是通过topic(话 ...
- Linux命令(一)——简单命令
一.简单命令 1.pwd命令 显示当前工作的全路径名. 2.date命令 显示系统当前的日期和时间. 3.who命令 显示当前已登录到系统的所有用户名,及其终端名和登录到系统的时间. 4.cal命令 ...
- Elasticsearch学习(一)————简单命令
Elasticsearch一.简介**Elasticsearch 是一个分布式的搜索和分析引擎,可以用于全文检索.结构化检索和分析,并能将这三者结合起来.Elasticsearch 基于 Lucene ...
随机推荐
- css样式重置方案 -解决浏览器差异
1.http://meyerweb.com/eric/tools/css/reset/ /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 2011 ...
- 使用webdriver + phantomjs + pdfkit 生成PDF文件
实例 #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on Dec 6, 2013 @author: Jay <smile665@gm ...
- PHP IDE phpstorm 常用快捷键
PHP IDE phpstorm 常用快捷键 投稿:junjie 字体:[增加 减小] 类型:转载 这篇文章主要介绍了PHP IDE phpstorm 常用快捷键,本文分别列出了mac系统和Win ...
- 20145317彭垚 《Java程序设计》第7周学习总结
20145317彭垚 <Java程序设计>第7周学习总结 教材学习内容总结 第十三章 时间与日期 13.1.1 时间的度量·即使标注为GMT(格林威治时间),实际上谈到的的是UTC(Uni ...
- thinkphp 设计思想
thinkphp 运行机制: thinkphp首先设置一些常量.然后运行Think对象(系统环境),装载think的运行环境,包括:自动加载.异常处理.功能核心等.环境准备好后,运行App对象(应用程 ...
- vue model双向绑定
view <div id='demo' class="container"> <input type="text" v-model='name ...
- Operand forms
Operand forms Computer Systems A Programmer's Perspective Second Edition
- StartSSL免费证书申请笔记
第一步:申请startssl账号 填写相应信息后,你所填写的邮箱会收到邮件 里面有一个用来验证的验证码 输入得到的.... 注册成功后会安装数字证书(注意:注册过程中没有叫输入账号密码,这也是通过证认 ...
- 【No.2 Ionic】Android打包
项目做完之后 接下来就是打包操作了,接下来直接说Android 打包操作 生成签名证书 keytool -genkey -alias vincentguo -keyalg RSA -validity ...
- Groovy 在eclipse中的使用
今天在写Groovy脚本的时候发现一个问题.如下图,element的elementIterator()方法不能智能显示,只能手动输入.而在eclipse中如果类a没有方法a,那么你是用"cl ...