|
|
Archives of the TeradataForum
Message Posted: Mon, 16 Jun 2003 @ 15:13:34 GMT
Subj: | | Re: Consecutive sequence sql logic |
|
From: | | Bankston Jr, Robert E |
This should work. It may have a syntax error or two. Let me know if you have any questions.
SELECT
* FROM MYTABLE
WHERE (ACCT) IN
(
SELECT
ACCT
FROM
(
SELECT
ACCT,
COUNT(*)
FROM
(
SELECT
ACCT,
PHONE,
COALESCE(MDIFF(PHONE,1,PHONE ASC),1) AS MDFF_PHN
FROM MYTABLE
GROUP BY 1) AS SBQRY
GROUP BY 1
WHERE MDFF_PHN = 1
HAVING COUNT(*) >= 5) AS SBQRY2
Rob Bankston
Teradata Certified Professional
UnumProvident - Data Warehouse
| |