Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Mon, 16 Jun 2003 @ 14:54:58 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Consecutive sequence sql logic
From:   Jason Fortenberry

This will probably require a stored procedure to solve correctly.

But till then, if you just want to probe your data, you could do something like below (assuming phone is stored as integer or can be casted as such):

sel acct, count(acct) cnt, max(phone) - min(phone) as Dif
from Table
Having cnt = 5 and Dif = 4
group by 1;

This will tell you who has exactly 5 consecutive numbers. You could then loop through manually and increase the 5 and 4 by 1 to see who has 6, 7, 8, etc. consecutive phone numbers. If you don't have to many then, perhaps a distinct union of these statements could generate a final list. Otherwise, a more elaborate stored procedure will be necessary. Just my 2 cents.


  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016