请问 在oracle中 怎样找出一列 数字的最大值, 和 最小值
例如 , table 中数据为
名称 序号 数值
A 1 100
A 2 200
A 3 300
我想得到的是: 最大值 A, 3, 300
最小值 A, 1, 100
该如何来写?
5 个解决方案
#1
select * from tablename where colname=(select max(colname) from tablename);
select * from tablename where colname=(select min(colname) from tablename);
select * from tablename where colname=(select min(colname) from tablename);
#2
楼上的,我同意
#3
select * from (select top 1 * from table8 order by 数值 desc ) a
union all
select * from (select top 1 * from table8 order by 数值) b
union all
select * from (select top 1 * from table8 order by 数值) b
#4
select * from (select a.*,rank() over(order by 数值 desc) rk from tab a) where rk=1
union
select * from (select a.*,rank() over(order by 数值) rk from tab a) where rk=1
union
select * from (select a.*,rank() over(order by 数值) rk from tab a) where rk=1
#5
to lynx1111:
oracle 是不支持top 语句的.
还是beckhambobo的办法比较好.
oracle 是不支持top 语句的.
还是beckhambobo的办法比较好.
#1
select * from tablename where colname=(select max(colname) from tablename);
select * from tablename where colname=(select min(colname) from tablename);
select * from tablename where colname=(select min(colname) from tablename);
#2
楼上的,我同意
#3
select * from (select top 1 * from table8 order by 数值 desc ) a
union all
select * from (select top 1 * from table8 order by 数值) b
union all
select * from (select top 1 * from table8 order by 数值) b
#4
select * from (select a.*,rank() over(order by 数值 desc) rk from tab a) where rk=1
union
select * from (select a.*,rank() over(order by 数值) rk from tab a) where rk=1
union
select * from (select a.*,rank() over(order by 数值) rk from tab a) where rk=1
#5
to lynx1111:
oracle 是不支持top 语句的.
还是beckhambobo的办法比较好.
oracle 是不支持top 语句的.
还是beckhambobo的办法比较好.