2016-06-24 54 views
2
SELECT A.EmailAddress, 
case when A.RegisteredProduct1 = 'Yes' then 'Yes' 
end  B.RegisteredProduct1 
FROM WebinarMasterDE B 
Join WebResponseDe A ON A.EmailAddress = B.EmailAddress 

當我試圖在營銷雲中運行此SQL查詢時,它給了我錯誤'。'附近的語法錯誤。無法弄清楚這個決議。營銷雲中的SQL查詢錯誤

回答

0

從別名

SELECT A.EmailAddress, 
case when A.RegisteredProduct1 = 'Yes' then 'Yes' 
end RegisteredProduct1 --Remove the B. from here as it is an alias name 
FROM WebinarMasterDE B 
Join WebResponseDe A ON A.EmailAddress = B.EmailAddress 
1

我相信你需要得到正確的case-when刪除B.。這是正確的case-when

case when A.RegisteredProduct1 = 'Yes' then 'Yes' else B.RegisteredProduct1 end 

這是你所需要的查詢:

SELECT A.EmailAddress, 
case when A.RegisteredProduct1 = 'Yes' then 'Yes' else B.RegisteredProduct1 end 
FROM WebinarMasterDE B 
Join WebResponseDe A ON A.EmailAddress = B.EmailAddress 

然而,最簡單的語法層面的解決辦法是增加一個缺少的逗號:

SELECT A.EmailAddress, 
case when A.RegisteredProduct1 = 'Yes' then 'Yes' 
end, -- this is it, the missing comma 
    B.RegisteredProduct1 -- this is a new column 
FROM WebinarMasterDE B 
Join WebResponseDe A ON A.EmailAddress = B.EmailAddress