SELECT失败3706:语法错误:预期之间

时间:2020-06-20 20:35:17

标签: teradata-sql-assistant

对于以下3706错误消息,新手将不胜感激: 预计单词“ Calls”和“ case”关键字之间会有所不同

SELECT distinct
b.emp_nbr,
b.prim_terr_desc, 
a.sales_terr_nbr,
TRIM (B.first_nm) ||' '|| TRIM (B.last_nm) as AE_Name,

count (distinct call_nbr) as Calls

case    (when   a.sale_call_chanl_desc LIKE 'Face to Face%' then 'F2F'
            when a.sale_call_chanl_desc = 'Telephone' then 'Phone'
            when a.sale_call_chanl_desc LIKE 'Web Meeting%' then 'Web_Meeting'
            end) as Channel
        
FROM isell_prod_view_db.sfdc_call_action a
LEFT OUTER JOIN  isell_prod_view_db.sfdc_customer_info c ON (a.cust_acct_nbr = c.cust_acct_nbr and a.rec_delt_flg = 'N')
LEFT OUTER JOIN isell_prod_view_db.sfdc_opportunity d ON (d.cust_acct_nbr = c.cust_acct_nbr and  d.delt_flg = 'N')
LEFT OUTER JOIN isell_prod_view_db.sfdc_user_profile b ON a.crte_by_user_key_nbr = b.user_key_nbr
LEFT OUTER JOIN isell_prod_view_db.sfdc_opportunity_item e ON  (e.oprty_key_nbr = d.oprty_key_nbr and e.delt_flg = 'N')

where a.sale_call_stat_desc = 'Completed'
 
and a.sales_div_nbr = '8'
and a.sales_grp_nbr = '9'
and a.sales_org_nbr ='30'
and b.prim_terr_desc LIKE ('8-9-30%')
and a.priv_entr_flg='N'
and a.sale_call_chanl_desc is not null
and CAST(a.call_dt AS date format 'MM/DD/YYYY') between '06/01/2019' and '05/31/2020'


group by 1,2,3,4

1 个答案:

答案 0 :(得分:0)

我重新编码了。这有效。我想在“ AS频道”后需要一个逗号

    SELECT distinct
b.emp_nbr,
TRIM (B.first_nm) ||' '|| TRIM (B.last_nm) as AE_Name,
b.prim_terr_desc, 
b.prim_terr_seg_nbr,
            
case    when CAST(a.call_dt AS date format 'MM/DD/YYYY') between '12/01/2019' and '02/29/2020' then 'Q3'
            when CAST(a.call_dt AS date format 'MM/DD/YYYY')  between '03/01/2020' and '05/31/2020' then 'Q4'
            end as Qtr,

count (distinct call_nbr) as Calls

FROM isell_prod_view_db.sfdc_call_action a
LEFT OUTER JOIN  isell_prod_view_db.sfdc_customer_info c ON (a.cust_acct_nbr = c.cust_acct_nbr and a.rec_delt_flg = 'N')
LEFT OUTER JOIN isell_prod_view_db.sfdc_opportunity d ON (d.cust_acct_nbr = c.cust_acct_nbr and  d.delt_flg = 'N')
LEFT OUTER JOIN isell_prod_view_db.sfdc_user_profile b ON a.crte_by_user_key_nbr = b.user_key_nbr
LEFT OUTER JOIN isell_prod_view_db.sfdc_opportunity_item e ON  (e.oprty_key_nbr = d.oprty_key_nbr and e.delt_flg = 'N')

where a.sale_call_stat_desc = 'Completed'
and a.sales_div_nbr = '8'
and a.sales_grp_nbr = '9'
and a.sales_org_nbr ='30'
and b.prim_terr_desc LIKE ('8-9-30%')
and A.rec_delt_flg = 'N'
and A.child_event_flg='N'
and a.priv_entr_flg='N'
and B.prim_terr_seg_desc not in ('No Coverage') 
and A.sale_call_chanl_desc in ('Telephone', 'Phone', 'Face to Face - Appt', 'Face to Face - No Appt', 'Web Meeting')
and B.prim_terr_seg_nbr not in ('3', '8', '25')   

and CAST(a.call_dt AS date format 'MM/DD/YYYY') between '12/01/2019' and '05/31/2020'

group by 1,2,3,4,5