Oracle课程档案,第三天
count(*):有多少行,对行做统计
count(x):列....
sum:和
avg:平均值
min:求最小值
max:求最大值
distinct:取出重复的值
count:计数
group by:分组
department_id:部门编号
having:对分组进行筛选
table:表
null:空表
组函数
①:avg: 平均值
②:count: 计数
③:max: 最大值
④:min: 最小值
⑤:sum: 和
分组数据
例:select deparment_id,job_id,avg(salary) from employees
from employees
group by department_id,job_id;
总结:分组数据中,select的字段只要不是组函数的,则必须出现在
group by中,否则会出错..... select 有的 group by 一定
要有,group by 有的select 不一定有....
使用组函数注意:
①:不能在where 子句中使用组函数
②:可以在 having 子句中使用组函数
当使用组函数作为条件的时候,只需要将where换成having即可
注意:having即可放在from后面,也可放到group by 的后面
例:select deparment_id,avg(salary)
from employees
having avg(salary) >6000
group by department_id
order by department_id asc;
③:组函数可以相互嵌套
例:select max(avg(salary))
from employees
group by department_id;
多表连接:
empno:工号
ename:姓名
deptno:部门编号
dept:部门
emp:表的名字
在where子句中指定连接条件
当被连接的多个表中存在同名字段时,必须在该字段前加上"表名"作为前缀
内连接:等值连接
左外连接:左外连接就是在内连接(等值连接)的基础上加上主表中的未匹配数据。
left outer join:左外连接 left join:左连接
右外连接:右外连接就是在内连接(等值连接)的基础上加上被连接表的不匹配数据。
right outer join:右外连接 right join:右连接
全外连接是在等值连接的基础上将左表和右表的未匹配数据都加上
全外连接:全外连接的等价写法,对同一表先做左连接,然后在做右连接。
full outer join:全外连接 full join:完全加入
on:为它们的连接条件。
Oracle课程档案,第三天的更多相关文章
- Oracle课程档案,第九天
lsnrctl status:查看监听状态 Oracle网络配置三部分组成:客户端,监听,数据库 配置文件:$ vi $ORACLE_HOME/network/admin/listener.ora v ...
- Oracle课程档案,第八天
存储管理 查询块的大小:show parameter db_block_size database:数据库 tablespace:表空间 datafile:数据文件 segments:段 extent ...
- Oracle课程档案,第七天
数据库管理 关闭数据库有4中方式: 1.shutdown modes 关机模式 2.shutdown normal 关机正常 3.shutdown immediate 立即关闭 ★★ 常用命令 4.s ...
- Oracle课程档案,第二天
salary:工资 order by:排序 desc:降序 hire:雇佣 单行函数 一周有七天 一月不一定只有30天 trunc:截取 dual:空表 last:最后 month:月份 round: ...
- Oracle课程档案,第十七天
flashback drop 闪回下降(删除)SQL> show parameter recyclebinSQL> purge recyclebin;(清除回收站)SQL> crea ...
- Oracle课程档案,第十六天
restore:恢复文件 recover: 恢复日志 丢失current日志组(正常关闭数据库):故障:SQL> select group#, status from v$log; 确认curr ...
- Oracle课程档案,第十四天
备份数据文件:SQL> select file_id, file_name from dba_data_files; backup:备用(备份) datafile:数据文件 backup tab ...
- Oracle课程档案,第十五天
restore:恢复数据文件 recover:写日志 1.redo(roll forward)重做 (前进) 2.undo(roll back) 撤销 (回滚) cp -r:删除一个目录 archiv ...
- Oracle课程档案,第十三天
配置可恢复性: ontrol_files:控制文件 parameter:参数 show:显示 select name from v$database; 查看当前的数据库★★ 控制文件SQL> s ...
随机推荐
- MYSQL常用的性能指标总结和归纳
(1) QPS(每秒Query量)QPS = Questions(or Queries) / uptimemysql> show global status like 'Question%';m ...
- ValueError: output parameter for reduction operation logical_and has too many dimensions ?
https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.all.html#numpy.all 运行示例,却发生错误 import ...
- 最新的Delphi版本号对照
The CompilerVersion constant identifies the internal version number of the Delphi compiler. It is de ...
- 【C++】解析C++运行环境的搭建
在本篇文章中,笔者会谈谈如何搭建C++的运行环境.在不同操作系统中,运行C++编译器的命令也各不相同,最常用的编译器是GNU编译器(Linux系统)和微软Visual Studio编译器(Window ...
- jqGrid时间转换
colModel: [ { label: '注册时间', name: 'createDate', index: 'create_date', width: 80, formatter:function ...
- 16.翻译系列:EF 6 Code -First中使用存储过程【EF 6 Code-First系列】
原文链接:https://www.entityframeworktutorial.net/entityframework6/code-first-insert-update-delete-stored ...
- 【转】WPF 与 WinForm 间的按键值(枚举)转换
There is a function for that in System.Windows.Input.KeyInterop static class. Try:var inputKey = Key ...
- pom文件中maven-assembly-plugin插件学习
一.使用场景 如果项目是微服务架构,可能用到这个插件的概率比较高,平时普通的项目不需要这样的实现方式. 如果项目内的一部分通用功能,不需要挨个引用,则需要将通用功能部分达成jar包. 二.Maven- ...
- 解决Protobuf生成的C#代码命名不规范问题
起因 通常使用Protobuf的步骤为 定义 .proto 文件 使用 protoc 生成对应语言的代码 以生成C#代码为例,使用如下命令: protoc -I ../protos --csharp_ ...
- Nginx SSL 结合Tomcat 重定向URL变成HTTP的问题
http://www.siven.net/posts/d925bb5d.html *********************************************** 问题描述 由于要配置服 ...