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> 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> /MAX(ID)KEEP(DENSE_RANKLASTORDERBYCOUNT(*)) ------------------------------------------ 1
time没用处 干脆去掉吧 select id from ( select id,count(id) num from table where time = '某一时间' group by id order by num desc ) where rownum =1;
这个可以: select time,max(id) from tablename group by time
查询所有时间的最大ID列表: select time,max(id) from tablename group by time 查询某一个时间点,例如201009的最大ID select max(id) from tablename where time='201009'
select b.id,max(b.a) from (select time,id,count(*) a from tablename where time='yyyy-mm-dd' group by time,id ) b group by b.id
group by time
from tb
where time between t1 and t2
group by id,time
(
select id,count(id) num,time from table
where time = '某一时间'
group by time,id
order by num desc
)
where rownum =1;
(
select id,count(id) num,time from table
where time = '某一时间'
group by time,id
order by num desc
)
where rownum =1;
--前面的修正下
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> /MAX(ID)KEEP(DENSE_RANKLASTORDERBYCOUNT(*))
------------------------------------------
1
select id from
(
select id,count(id) num from table
where time = '某一时间'
group by id
order by num desc
)
where rownum =1;
select time,max(id)
from tablename
group by time
select time,max(id) from tablename group by time
查询某一个时间点,例如201009的最大ID
select max(id) from tablename where time='201009'