直接用查询就可以得到你要的结果:
select ID,NAME,VISIT_TIME
from
(
select ID,NAME,VISIT_TIME
,CNT
,max(CNT) over () MX
from
(
select ID,NAME,VISIT_TIME
,count(MINDATE) over (partition by MINDATE) CNT
from
(
select ID,NAME,VISIT_TIME
,MINDATE
from
(
select ID,NAME,VISIT_TIME
,row_number() over (order by VISIT_TIME) RN
from VISTER t
where t.NAME = '张三'
) t
model
dimension by (t.RN)
measures(ID,NAME,VISIT_TIME,trunc(VISIT_TIME) VISIT_DATE,trunc(t.VISIT_TIME) as MINDATE)
rules upsert all
(
MINDATE[any] =
case
when VISIT_DATE[currentv()] - VISIT_DATE[currentv()-1] <= 1 then
MINDATE[currentv()-1]
else
VISIT_DATE[currentv()]
end
)
order by VISIT_TIME
)
)
)
where CNT = MX
哪里要这么复杂....鉴于你按每10分钟来连续排列有点奇怪..我写了一个按照日期来连续的sql..
select b.name, min(b.visit_time), max(b.visit_time)
from (
select a.*, (a.visit_time - rownum) cc
from (
select * from vister order by name, visit_time
) a
) b
group by b.name, b.cc;
我给你个思路吧!相必你基本的orcacl操作都会,因为我没有装这相数据,所以也没有办法给你写代码!
第一步:先有count(日期),name,日期(格式为年月日) group by 日期,name (对count进行高到低排列)
第二步:取出最高日期,
第三步:显示最高日期下的详细信息;
参照一下这个 http://zhidao.baidu.com/question/1860129509886885707.html?oldq=1
建议使用存储过程吧。