|
|
Archives of the TeradataForum
Message Posted: Fri, 05 Nov 2010 @ 17:12:00 GMT
Subj: | | Re: Compare data in same column |
|
From: | | Good, Ken |
select TT.member_id,
Case when TwoIn.member_id is null Then 'No' Else 'Yes' End As Two_In_Twelve_Months from
TheTable TT left outer join (select a.member_id from TheTable a, TheTable b where
a.member_id = b.member_id and a.date_admitted <> b.date_admitted and (a.date_admitted
between b.date_admitted and b.date_admitted + 365 or b.date_admitted between
a.date_admitted and a.date_admitted + 365) group by 1) TwoIn on TT.member_id =
TwoIn.member_id group by 1,2;
Kenneth M. Good, BCIS, MIT
State of Michigan/DTMB/Infrastructure Services Data Center Services/Enterprise Platform
Services Data Warehouse Support
| |