我正在使用MS Access 2007.每当我键入Left Join时,我都会收到一条错误消息,指出不支持Left Join。这是SQL
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);
有人可以使用上面的代码向我展示左边连接的位置,以便允许每个Race的行显示在表格中吗?另外,您能否告诉我如何在此代码中将Null值替换为0?我试图实施NZ(),但一直没有成功。
请帮忙。
答案 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)
你有一个ON条件,它引用[Letter Status],但你的源表中没有[Letter Status] ....你有一个名为[Status]。
首先在查询设计器中构建JOIN,这样您就知道您将使用Access接受的SQL。
简化这个事情,直到你把JOIN整理出来。在JOIN工作之后,摆脱Switch,TRANSFORM,PIVOT和GROUP BY。