2011-06-27 140 views
0

工作我使用的MS Access 2007年。每當我鍵入左連接,我得到,說左連接,不支持一個錯誤。這裏的SQLSQL - LEFT JOIN不會與switch語句

TRANSFORM Count([Letter Status].Customer_ID) AS CountOfCustomer_ID 
SELECT Switch(
      [Race_1]=1,"White", 
      [Race_1]=2,"Black", 
      [Race_1]=3,"Asian", 
      [Race_1]=4,"Hispanic/Latino", 
      [Race_1]=5,"American Indian/ Alaskan Native", 
      [Race_1]=6,"Native Hawaiian or Pacific Islander", 
      [Race_1]=7,"Multiracial", 
      [Race_1]=8,"Other", 
      [Race_1]=9,"Unknown" 
     ) AS Race 
FROM Demographics 
    INNER JOIN (
     [Status] 
     INNER JOIN 
      Research 
       ON [Status].Customer_ID = Research.Customer_ID 
     ) 
     ON (Demographics.ID = [Letter Status].Customer_ID) 
     AND (Demographics.ID = Research.Customer_ID) 
WHERE ((([Status].Count)=1)) 
GROUP BY [Status].Count, Demographics.Race_1 
ORDER BY Research.Store_site 
PIVOT Research.Store_site In (1,2,3,4,5,6,7,8,9,10); 

可能有人請使用上面的代碼,告訴我在哪裏放置左聯接,以允許每個種族在表中顯示行?另外,你能告訴我如何在這段代碼中用0代替空值嗎?我試圖實施新西蘭(),但沒有成功。

請幫助。

回答

3

你FROM子句仔細看看。

FROM Demographics 
    INNER JOIN (
     [Status] 
     INNER JOIN 
      Research 
       ON [Status].Customer_ID = Research.Customer_ID 
     ) 
     ON (Demographics.ID = [Letter Status].Customer_ID) 
     AND (Demographics.ID = Research.Customer_ID) 

有內部條件是指[信狀態],而[信狀態]不包含源表中的....你確實有一個叫[狀態]。

開始通過建立這些連接的查詢設計器,讓你知道你開始使用SQL哪個接入接受。

而直到你得到的加入整理簡化了這件事情。擺脫開關,轉換,PIVOT和GROUP BY,直到後你的JOIN工作。

+1

+1的QBE建議。 –