有一个这样的表(a,b,c)现在我如果想做这样的操作,先按a分组找出b的最大值,再在结果中找出c的最大值的那一个记录。这样的SQL语言要怎么写?
解决方案 »
- 年百万记录的表如何构建!!!!
- 求一个特别的oracle查询语句
- 可以根据rownum来删除某一条记录吗?
- 求一个视图条件语句!各位大侠务必帮忙~~
- 请教,怎样在oracle 中用什么函数可以把 varchar型的数据为2004/12/02 上午 10:47:08 转成 日期型,以便我做查询比较.谢谢
- 要实现以下样式。SQL如何写?求救!
- 能不能对多条件查询用存储过程来实现?
- 关于检索数据的问题
- oracle9i中如何启动enterprise manager 登陆到managerment server上?
- 帮忙看看,我要怎么在这条sql插入数据,谢谢各路大神了。
- 如何转换成Oracle代码?高分求!
- 求教登录oracle时出现‘ORA-12537: TNS: 连接关闭’问题的解决方法
select 1 as a, 2 as b, 3 as c from dual
union all
select 1,2,4 from dual
union all
select 1,2,8 from dual
union all
select 2,3,2 from dual
union all
select 2,3,8 from dual
union all
select 3,3,9 from dual
union all
select 3,3,8 from dual
)
select a ,max(b),max(c) from t
group by awith t as (
select 1 as a, 2 as b, 3 as c from dual
union all
select 1,2,4 from dual
union all
select 1,2,8 from dual
union all
select 2,3,2 from dual
union all
select 2,3,8 from dual
union all
select 3,3,9 from dual
union all
select 3,3,8 from dual
)
select a ,max(b),max(c) from t
group by aA MAX(B) MAX(C)
---------------------- ---------------------- ----------------------
1 2 8
2 3 8
3 3 9
select * from table where c in(select max(c) from (select * from table where b in(select max(b) from table group by a))as table2 group by a);
group by a