iobox,
1 with t1 as
2 (
3 select 191 as param_id,'21.09.2012 16:31:00' as data_date, 11 as value from dual union all
4 select 191,'21.09.2012 16:32:00', 12 from dual union all
5 select 191,'21.09.2012 16:33:00', 10 from dual union all
6 select 191,'21.09.2012 18:01:00', 12 from dual union all
7 select 191,'21.09.2012 18:02:00', 10 from dual union all
8 select 191,'22.09.2012 19:22:00', 14 from dual union all
9 select 191,'22.09.2012 19:23:00', 17 from dual union all
10 select 191,'22.09.2012 19:25:00', 18 from dual union all
11 select 191,'22.09.2012 19:26:00', 19 from dual union all
12 select 191,'23.09.2012 21:54:00', 19 from dual union all
13 select 191,'23.09.2012 21:55:00', 19 from dual
14 )
15 ,t as
16 (select param_id,to_date(data_date,'dd.mm.yyyy hh24:mi:ss') dt,value from t1)
17 ,tt as (
18 select
19 t.*
20 ,sum(decode(greatest(value,10),10,1,0)) over (partition by param_id,trunc(dt) order by dt desc) gr
21 from t
22 )
23 select param_id,min(dt),count(*)
24 from tt
25 group by param_id,trunc(dt),gr
26* order by 1,2
SQL> /
PARAM_ID MIN(DT) COUNT(*)
---------- ------------------- ----------
191 21.09.2012 16:31:00 3
191 21.09.2012 18:01:00 2
191 22.09.2012 19:22:00 4
191 23.09.2012 21:54:00 2
SQL>
.....
stax