Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Reduce To Ranges aggregate function
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dieter Noeth  
View profile  
 More options Oct 21 2006, 12:19 pm
Newsgroups: comp.databases.oracle.misc
From: Dieter Noeth <dno...@gmx.de>
Date: Sat, 21 Oct 2006 18:19:35 +0200
Local: Sat, Oct 21 2006 12:19 pm
Subject: Re: Reduce To Ranges aggregate function

Mike King wrote:
>  ID
> ----
> 1
> 2
> 3
> 4
> 5
> 11
> 12
> 45

> Reduced form: 1-5,11-12,45

Consecutive values are easy to find using OLAP-functions:

select
   min(id), max(id)
from
  (
   select
     id,
     id - row_number() over (order by id) grp
   from t
  ) dt
group by grp

If id is not unique use dense_rank instead of row_number...

Dieter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.