View Single Post

   
  #3 (permalink)  
Old 04-08-2008, 11:15 AM
Dieter Noeth
 
Posts: n/a
Default Re: eliminating gaps

Dieter Noeth wrote:

> select
> a,
> min(b),
> max(b)
> from
> (
> select
> a - rank() over (partition by A order by b asc) as grp,
> a
> from mytab
> ) dt
> group by a, grp
> order by 1,2;


Sorry, of course it's:

select
a,
min(b),
max(b)
from
(
select
b - rank() over (partition by A order by b asc) grp,
a,
b
from mytab
) dt
group by a, grp
order by 1,2;

Dieter
Reply With Quote