|
|
Archives of the TeradataForum
Message Posted: Mon, 16 Jun 2003 @ 14:59:38 GMT
Subj: | | Re: Consecutive sequence sql logic |
|
From: | | Burton, Bruce |
here is what I came up with:
sel distinct acct
from
(sel
file1.acct, file1.mobile, file2.mobile, file3.mobile, file4.mobile,
file5.mobile
from
(select acct, cast (mobile as decimal(12,0)) as mobile
from mktdb.p816_master
where bus_ind=1 and bus_seg ='A') file1
inner join
(select acct, cast (mobile as decimal(12,0)) as mobile
from mktdb.p816_master
where bus_ind=1 and bus_seg ='A') file2
on file1.acct=file2.acct and file1.mobile-file2.mobile =1
inner join
(select acct, cast (mobile as decimal(12,0)) as mobile
from mktdb.p816_master
where bus_ind=1 and bus_seg ='A') file3
on file2.acct=file3.acct and file2.mobile-file3.mobile =1
inner join
(select acct, cast (mobile as decimal(12,0)) as mobile
from mktdb.p816_master
where bus_ind=1 and bus_seg ='A') file4
on file3.acct=file4.acct and file3.mobile-file4.mobile =1
inner join
(select acct, cast (mobile as decimal(12,0)) as mobile
from mktdb.p816_master
where bus_ind=1 and bus_seg ='A') file5
on file4.acct=file5.acct and file4.mobile-file5.mobile =1)
unique_acct
| |