【问题标题】:SELECT Failed 3706: Syntax error: Expected something betweenSELECT Failed 3706: 语法错误: 预期介于
【发布时间】:2020-10-10 22:53:20
【问题描述】:

对于以下 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

【问题讨论】:

  • Calls后面需要逗号吗?

标签: teradata-sql-assistant


【解决方案1】:

我重新调整了代码。这行得通。我想我需要在“AS Channel”之后加一个逗号

    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

【讨论】:

    猜你喜欢
    • 2020-05-14
    • 1970-01-01
    • 2019-05-08
    • 2021-02-17
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    相关资源
    最近更新 更多