选择要计算的问题

时间:2015-12-16 13:30:57

标签: sql select

我有一个问题,我不知道该怎么做。

我加入了桌子,我需要了解一个人在过去半年收到的电子邮件数量。 当前代码我如何选择输出

SELECT 
account.EXT_STRING0 as client_ID,
account.EXT_STRING2 as Email,
activity.TEMPLATE_NAME as Template_name,
activity.NAME as campaign_name,
activity.EXECUTION_ID, -- unique campaign ID
activity.SEND_DATE,
Activity.OPEN_DATE,
Activity.CLICK_DATE
FROM  
    crmautomation.oocke1_account account 
Join 
    crmautomation.oocke1_activity activity 
    ON 
     (account.object_id = activity.rep_contact)
left JOIN 
    crmautomation.OBJ_VAL val1
       ON val1.obj_row_id = activity.CAMPAIGN_TYPE AND (val1.OBJ_VAL_ID in(4250950)) 
left JOIN 
    crmautomation.OBJ_VAL val2
       ON val2.obj_row_id = activity.CAMPAIGN_TYPE AND (val2.OBJ_VAL_ID in(4250951))
where activity.TEMPLATE_NAME= ('cabin_surprise_et')
and activity.SEND_DATE >('2015.12.01')

example output

1 个答案:

答案 0 :(得分:0)

我认为你在select语句中遗漏了逗号,这只是sql语法错误

SELECT 
account.OBJECT_ID,
activity.TEMPLATE_NAME,
activity.SEND_DATE,
activity.OPEN_DATE,
activity.ACTIVITY_TYPE
From 
    crmautomation.oocke1_account account 
Join 
    crmautomation.oocke1_activity activity 
ON 
 (account.object_id = activity.rep_contact)
where Activity.ACTIVITY_TYPE is not NULL