一共两列 id time 1 201009 2 201009 3 201009 1 201009 1 201009 2 201009 4 201009 求,,某一时间点击量最大的id号?(oracle)select time,max(id) from tablename group by time SQL code:
select id,time,max(id) keep(dense_rank last order by count(*)) 最大id from tb where time between t1 and t2 group by id,time
select max(id) from tb where time =某一时间 select id,time from ( select id,count(id) num,time from table where time = '某一时间' group by time,id order by num desc ) where rownum =1; select id from ( select id,count(id) num,time from table where time = '某一时间' group by time,id order by num desc ) where rownum =1; SQL code:
--前面的修正下 SQL> edi 已写入 file afiedt.buf
1 select max(id) keep(dense_rank last order by count(*)) 2 from tb 3 where time ='201009' 4* group by id SQL> /