日期:2014-05-17 浏览次数:20692 次
with t as( select '11:00' time1, '2' value1,'3' value2 from dual union all select '11:30' time1, '4' value1,'5' value2 from dual union all select '11:00' time1, '3' value1,'3' value2 from dual union all select '11:30' time1, '4' value1,'3' value2 from dual ) select tt.time1,tt.value1,tt.value2 from ( select t.time1,t.value1,t.value2,row_number() over(partition by t.time1 order by t.value1) rn from t) tt where tt.rn = 1
------解决方案--------------------
借用滤重的语句也可以
select * from from table where rowid in ( select max(rowid) from table group by time)
------解决方案--------------------
select * from temp where rowid in (select max(rowid) from temp group by time)
------解决方案--------------------
为啥上面都写的这么麻烦呢? 这样可以么
select time , max(vale1), max(value2) from A group by time
------解决方案--------------------
用row_number()(partition by 字段 order by 字段 ) 是比较好的方法!
------解决方案--------------------
select time ,min(vale1) ,max(vale2) from table group by time
------解决方案--------------------
+1 天朝的人都喜欢拿简单的事复杂化。