Archives of the TeradataForum
Message Posted: Thu, 26 Mar 2009 @ 15:40:12 GMT
Subj: | | Re: Sub query in case statement |
|
From: | | Anderson, Dirk |
The example you provided does not need a subselect....you can get the answer without a subselect....
SEL ORG_CD,
CASE
WHEN ORG_LEVEL = 'SUB_LOB' THEN 'Y'
ELSE 'N'
END
FROM hr_nonhr a
;
Or, you could do a self-join...
SEL A.ORG_CD,
CASE
WHEN b.ORG_CD IS NOT NULL THEN 'Y'
ELSE 'N'
END
FROM hr_nonhr a
LEFT OUTER JOIN hr_nonhr b
ON a.ORG_CD = B.ORG_CD
AND B.ORG_LEVEL='SUB_LOB'
;
Dirk Anderson
Architect
Enterprise Information Management
|