oracle 中的group by ,having 和order by
2016-06-21 15:58
567 查看
一 group by 子句
1.group by 的作用
就是可以将数据分成若干个列
2.group by 的语法格式:
select column,.... function(column)... from table_name where condition group by column...
3.使用group by子句注意的问题:
(1).如果group by 子句中包含多个列,则先按第一个列进行排序,当第一个列有相同的数据时,按第二列排序,以此类推。
(2).在select 列表中所有不包含在多行函数中的列都必须写在group by 子句中
(3).包含在group by 中的列不必包含在select 子句中
(4).注意group by中不能使用select子句中起的别名
二Having子句
1.having的作用
筛选分组出来的数据
2.为什么要使用having
我们在where 中没法使用多行函数,但是在having中可以使用
3.语法格式
select column,.... function(column)... from table_name where condition group by column... having function(column)_condition
4.注意的问题
当组函数是条件是,使用HAVing,必须跟在group by后面使用,它是作用于表,其他一般使用where,where作用于表
三order by
1.order by的作用
按指定的方式进行排序
2.语法格式
select column,.... function(column)... from table_name where condition group by column... having function(column)_condition order by column....
3.注意的问题
(1)默认是升序排列,如果想降序排列,则列后面加desc
(2)如果有多个列排序,则先按第一列排序,有相同,在按第二列排序
1.group by 的作用
就是可以将数据分成若干个列
2.group by 的语法格式:
select column,.... function(column)... from table_name where condition group by column...
3.使用group by子句注意的问题:
(1).如果group by 子句中包含多个列,则先按第一个列进行排序,当第一个列有相同的数据时,按第二列排序,以此类推。
(2).在select 列表中所有不包含在多行函数中的列都必须写在group by 子句中
(3).包含在group by 中的列不必包含在select 子句中
(4).注意group by中不能使用select子句中起的别名
二Having子句
1.having的作用
筛选分组出来的数据
2.为什么要使用having
我们在where 中没法使用多行函数,但是在having中可以使用
3.语法格式
select column,.... function(column)... from table_name where condition group by column... having function(column)_condition
4.注意的问题
当组函数是条件是,使用HAVing,必须跟在group by后面使用,它是作用于表,其他一般使用where,where作用于表
三order by
1.order by的作用
按指定的方式进行排序
2.语法格式
select column,.... function(column)... from table_name where condition group by column... having function(column)_condition order by column....
3.注意的问题
(1)默认是升序排列,如果想降序排列,则列后面加desc
(2)如果有多个列排序,则先按第一列排序,有相同,在按第二列排序
相关文章推荐
- CentOS7安装Oracle 11gR2 图文详解
- PLS-00306:错误解决思路 - OracleHelper 执行Oracle函数的坑
- linux oracle DISPLAY 安装界面解决方案
- plsql连接oracle数据库
- oracle 关于with admin option和with grant option说明
- oracle10g安装
- oracle 11g 启动实例 ORA-00845: MEMORY_TARGET not supported on this system
- 如何在Oracle中增加修改删除字段
- Oracle索引小结
- oracle数据泵备份恢复
- 解决X64操作系统PL/SQL连接报错问题 make sure you have the 32 bits oracle client installed
- oracle数据库常用的99条查询语句
- Oracle 11G在用EXP 导出时,空表不能导出解决
- ORACLE11g导入导出数据
- shp2sdo工具导入shp文件到oracle
- oracle中,改变表名和字段名的大小写
- oracle SQl语言中的函数
- oracle中110个常用函数介绍
- oracle导入导出
- Oracle创建表语句语法详解