home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,191 of 2,288   
   Bertrand Guillaumin to All   
   Re: deducing ranges in SQL   
   21 Mar 06 21:34:12   
   
   From: bertrand.guillaumin@aliceadsl.fr   
      
   Try something like this :   
      
   SELECT D_NO , to_char(Min(Val)) || '-' || to_char(Max(Val))   
   Group By D_No   
      
   Hope it will help.   
      
   Oxnard a écrit :   
   > Oracle 9.2.0.6 in AIX   
   >   
   > I am trying to find ranges and where the range ends for each d_no:   
   > The increment of val is one   
   >   
   > My example is:   
   >   
   > select * from t1   
   >   
   > d_no    val   
   > 1        20   
   > 1        21   
   > 1       22   
   > 1       23   
   > 1       25   
   > 1      1503   
   > 1      1504   
   > 3      502   
   > 3       503   
   > 3        504   
   > 3        600   
   >   
   > I am trying to come up with an SQL which would produce an output of   
   >   
   > d_no      the_range   
   > 1         20-23   
   > 1         25   
   > 1         1503-1504   
   > 3         502-504   
   > 3         600   
   >   
   > I have tried using some of the analytic functions and got close with lead   
   > but not quite. I could do a cursor in   
   > PL/SQL but the table is so huge it takes way to long. In fact I did do this   
   > on a small table. It worked just fine.   
   > Also what I am showing as a table is really an in-line view of a couple of   
   > tables I have joined.   
   >   
   > Any ideas would really be helpful   
   >   
   > Thank you   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca