|
|
Archives of the TeradataForum
Message Posted: Thu, 25 Mar 2004 @ 18:57:43 GMT
Subj: | | Re: Populating one column with data from either of two table. |
|
From: | | Scott Thompson |
| I have been thinking of a good efficient way to do this and I could use the help ... | |
is this perhaps what you're looking for? :
SELECT (CASE WHEN LA.column_to_check = 'what i want'
then LA.column_i_want
WHEN A.column_to_check = 'meets secondary conditions'
then A.column_i_want
WHEN LA.column_to_check2 = A.column_to_check2
then LA.column_i_want2||A.column_i_want2
.
.
.
ELSE 'stick generic message in col1'
END) as col1,
col2,
col3, .... coln
From BA.DLY_LN_ACCNT LA, BACURRENT.Ln_Dt_Rng LDR,
BA.Dly_AccNT A, BA.Dly_Accnt_Risk AR,
ba.Dly_Ppant PART
WHERE LA.process_dt = LDR.end_extract
AND A.ba_accnt_nbr = LA.ba_accnt_nbr
And A.process_dt = LA.process_dt
AND A.ba_accnt_nbr = AR.ba_accnt_nbr
And A.process_dt = AR.process_dt
AND PART.ba_accnt_nbr = A.ba_accnt_nbr
And PART.process_dt = A.process_dt
obviously, change the column names, comparison conditions, and return values in the case statement to something more specific to your
actual tables and columns and suitable to your needs.
| |