Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 11 Feb 2003 @ 18:11:41 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   I'm stumped...case logic on a left join subquery vs. case logic on a select query
 
From:   Burton, Bruce

Anyone have any idea why query #1 runs fine but when I take that block of code and use it in a left join I get the following error code:

Code = 3706.
3706:  Syntax error: expected something between '(' and the word 'pc'.

Any help would be greatly appreciated! Maybe I'm overlooking something very simple here but I can't seem to figure it out.


Thanks,

Bruce


query #1 - case on select clause:
---------------------------------

sel acct_id,
max(case when pc.mcrovsn_sgmnt_clutr_id is null then
pd.mcrovsn_sgmnt_clutr_id else pc.mcrovsn_sgmnt_clutr_id
end) as mcrovsn_segment_clutr_id
from edwviews.acct_nm_addr_hist ah
left join edwviews.loc_addr la
ON ah.addr_id = la.addr_id
left join edwviews.mcrovsn_sgmnt_postl_cd pc
on length(pc.postl_cd) =9 and pc.postl_cd=trim(loc_addr_postl_cd ||
la.loc_addr_postl_cd_plus)
left join edwviews.mcrovsn_sgmnt_postl_cd pd
on length(pd.postl_cd) =5 and pd.postl_cd=substr(loc_addr_postl_cd,1,5)
group by acct_id

query #2 - case on select clause after included in a left join:
---------------------------------------------------------------

sel * from edwviews.acct   <---- same as above except left joined to
another table
left join
(sel acct_id,
max(case when pc.mcrovsn_sgmnt_clutr_id is null then
pd.mcrovsn_sgmnt_clutr_id else pc.mcrovsn_sgmnt_clutr_id
end) as mcrovsn_segment_clutr_id
from edwviews.acct_nm_addr_hist ah
left join edwviews.loc_addr la
ON ah.addr_id = la.addr_id
left join edwviews.mcrovsn_sgmnt_postl_cd pc
on length(pc.postl_cd) =9 and pc.postl_cd=trim(loc_addr_postl_cd ||
la.loc_addr_postl_cd_plus)
left join edwviews.mcrovsn_sgmnt_postl_cd pd
on length(pd.postl_cd) =5 and pd.postl_cd=substr(loc_addr_postl_cd,1,5)
group by acct_id) micro
on acct.acct_id=micro.acct_id

-end-


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023