oracle取一条记录中多个列的最大值和最小值
2017-04-17 10:06
357 查看
1.使用oracle内置的greatest()和least()函数,具体示例如下:
select 5 as col1,6 as col2,9 as col3,1 as col4 from dual;
--------------------------------------
col1 | col2 |col3 |col4
5 6 9 1
select greatest(5,6,9,1) as maxcol, least(5,6,9,1) as mincol from dual;
--------------------------------------
maxcol | mincol
9 1
select 5 as col1,6 as col2,9 as col3,1 as col4 from dual;
--------------------------------------
col1 | col2 |col3 |col4
5 6 9 1
select greatest(5,6,9,1) as maxcol, least(5,6,9,1) as mincol from dual;
--------------------------------------
maxcol | mincol
9 1
相关文章推荐
- Sql语句 表中相同的记录(某个字段)只显示一条,按照时间排序显示最大或最小
- sql 删除重复记录,只保留ID号最小(或最大)的一条
- 统计向oracle每个表中插入一条记录时 , 占用的最大空间
- 删除oracle 表中重复数据sql语句、保留rowid最小的一条记录
- ORACLE单表理论最大记录数
- Oracle建立DBLINK的步骤记录,其实就是一条CREATE DATABASE LINK语句!
- oracle 中随机取一条记录的两种方法
- oracle 中随机取一条记录的两种方法
- 返回一条记录,显示1-12月(telfeedate字段)每个月的销售总额(factration字段)[ORACLE]
- 查询表内多条记录的最大值一条
- mysql,oracle里删除重复记录,只保留一条(除了自增长字段,其他的字段完全相同为相同记录)
- PLSQL中lag和lead取前一条/后一条以及分组取最大/最小
- 论oracle随机查询一条记录
- oracle 存储过程 stored procedure 查询一条记录或多条记录
- oracle 一个表里有多条记录引用另一个表的主键 并获取此表的最后一条记录
- 求一组数据中最大的值(也可以理解为近三个月是最后一条记录)
- ORACLE中SQL取最后一条记录的几种方法
- 用一条查询语句取出price的和最大的连续5条记录
- Oracle中利用一条SQL生成10万条记录
- Oracle pl/sql for循环 取出下一条记录