Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Why subqueries in case are not working in teradata? - response (8) by AshishPatil

$
0
0

Hi Dieter,
 
 As you said the syntax should work on TD 13.00, but same is not working on 13.10. Can you pls suggest some changes to achieve same on TD.
Below is my complete query,
 

select distinct a.asset_wid,a.PR_VIS_ORG_WID,a.SELL_DT_WID,a.prod_wid,a.contact_wid,a.accnt_wid,

case 

when 

(a.contact_wid <> 0 and W_PARTY_PER_D.x_district is not null ) then

 (case when W_PARTY_PER_D.X_DISTRICT in (select upper(WC_ORG_EXT_XM_F.attrib_04) from wc_org_ext_xm_f where pf_org_wid = a.PR_VIS_ORG_WID) 

 then 0 else 1 end )

else 

(case when W_PARTY_ORG_D.X_DISTRICT in (select upper(WC_ORG_EXT_XM_F.attrib_04) from wc_org_ext_xm_f where pf_org_wid = a.PR_VIS_ORG_WID)

 then 0 else 1 end ) 

 end infringement

from (

SELECT 

W_ASSET_D.ROW_WID asset_wid, 

W_ASSET_F.PR_VIS_ORG_WID PR_VIS_ORG_WID, 

W_ASSET_F.SELL_DT_WID SELL_DT_WID, 

min(WC_PRODUCT_DH.PROD_WID) prod_wid,

W_ASSET_F.contact_wid contact_wid,

w_asset_f.Accnt_wid accnt_wid

FROM

W_ASSET_D, W_ASSET_F, W_PRODUCT_DH, W_INT_ORG_D ,WC_PRODUCT_DH,w_product_d

WHERE

W_ASSET_D.ROW_WID = W_ASSET_F.ASSET_WID and

W_ASSET_F.PROD_WID = W_PRODUCT_DH.PROD_WID and

W_INT_ORG_D.ROW_WID = W_ASSET_F.PR_VIS_ORG_WID AND

WC_PRODUCT_DH.LVL8ANC_PROD_ID = W_PRODUCT_DH.LVL8ANC_PROD_ID  and

w_product_d.row_wid = W_PRODUCT_DH.prod_wid and

w_product_d.x_BU_UNIT in ('TMPC','TM') and

W_INT_ORG_D.BU_NAME = 'TMPC' 

group by   W_ASSET_D.ROW_WID,W_ASSET_D.LICENSE_NO,W_ASSET_F.PR_VIS_ORG_WID,W_ASSET_F.contact_wid,w_asset_f.Accnt_wid,

W_ASSET_F.SELL_DT_WID) a ,

WC_ORG_EXT_XM_F,

W_PARTY_PER_D,

W_PARTY_ORG_D

where 

WC_ORG_EXT_XM_F.PF_ORG_WID = a.PR_VIS_ORG_WID and 

WC_ORG_EXT_XM_F.prod_wid  = a.prod_wid and

a.contact_wid = W_PARTY_PER_D.row_wid and 

a.accnt_wid = W_PARTY_ORG_D.row_wid and

a.sell_dt_wid = to_number(to_char(sysdate,'yyyymmdd'))-1 and

WC_ORG_EXT_XM_F.attrib_04 is not null

 

 

 

 

Thanks and Regards,

Ashish


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>