我正在尝试运行以下查询,但我在MS Access上收到错误,“加入操作中的语法错误”
以下是我的查询 -
select
v.City,
v.CURRENCY,
(
select
Sum(VSDEH.NORM_PRICE_MEDIUM*BCIEH.WEIGHT_OR_MULTIPLIER) AS BaseMedium
FROM (
// This line has error ->> ([VSURVEYDATA] AS VSDEH INNER JOIN [BASKET_CONTENT_ITEMS] AS BCIEH ON VSDEH.ITEM = BCIEH.ITEM_ID)
INNER JOIN [EXCHANGE_RATES] AS EXREH on VSDEH.SURVEY_DATE = EXREH.RATE_DATE AND VSDEH.CURRENCY = EXREH.BASE_CURRENCY_ID
)
WHERE (
VSDEH.SURVEY_DATE = v.SURVEY_DATE
AND BCIEH.LINE_OF_BUSINESS_ID='ICOL'
AND BCIEH.BASKET_ID= b.BASKET_ID
AND BCIEH.ITEM_ID not in ( '215','216','326')
AND EXREH.HOST_CURRENCY_ID= ex.HOST_CURRENCY_ID
AND EXREH.RATE_SET_ID=' '
AND VSDEH.CITY in (v.City)
)
GROUP BY VSDEH.CITY, VSDEH.CURRENCY
) as BaseMediumEH
FROM ((
([VSURVEYDATA] AS VSDEH INNER JOIN [BASKET_CONTENT_ITEMS] AS BCIEH ON VSDEH.ITEM = BCIEH.ITEM_ID)
INNER JOIN [EXCHANGE_RATES] AS EXREH on VSDEH.SURVEY_DATE = EXREH.RATE_DATE AND VSDEH.CURRENCY = EXREH.BASE_CURRENCY_ID
)
INNER JOIN qSTAHostCity ON VSURVEYDATA.CITY = qSTAHostCity.HostCity)
WHERE (
v.SURVEY_DATE = [Survey Date]
AND b.LINE_OF_BUSINESS_ID='ICOL'
AND b.BASKET_ID= [Basket ID]
AND ex.HOST_CURRENCY_ID='USD'
AND ex.RATE_SET_ID=' ')
GROUP BY v.CITY, v.CURRENCY ORDER BY v.CITY
有谁能建议我在这里做错了什么?
由于
答案 0 :(得分:0)
你错过了两个表别名:
将***** TableAlias *****替换为您需要加入的表别名。
select
v.City,
v.CURRENCY,
(
select
Sum(VSDEH.NORM_PRICE_MEDIUM*BCIEH.WEIGHT_OR_MULTIPLIER) AS BaseMedium
FROM (
// This line has error ->> ([VSURVEYDATA] AS VSDEH INNER JOIN [BASKET_CONTENT_ITEMS] AS BCIEH ON VSDEH.ITEM = BCIEH.ITEM_ID) *****TableAlias*****
INNER JOIN [EXCHANGE_RATES] AS EXREH on VSDEH.SURVEY_DATE = EXREH.RATE_DATE AND VSDEH.CURRENCY = EXREH.BASE_CURRENCY_ID
)
WHERE (
VSDEH.SURVEY_DATE = v.SURVEY_DATE
AND BCIEH.LINE_OF_BUSINESS_ID='ICOL'
AND BCIEH.BASKET_ID= b.BASKET_ID
AND BCIEH.ITEM_ID not in ( '215','216','326')
AND EXREH.HOST_CURRENCY_ID= ex.HOST_CURRENCY_ID
AND EXREH.RATE_SET_ID=' '
AND VSDEH.CITY in (v.City)
)
GROUP BY VSDEH.CITY, VSDEH.CURRENCY
) as BaseMediumEH
FROM ((
([VSURVEYDATA] AS VSDEH INNER JOIN [BASKET_CONTENT_ITEMS] AS BCIEH ON VSDEH.ITEM = BCIEH.ITEM_ID) *****TableAlias*****
INNER JOIN [EXCHANGE_RATES] AS EXREH on VSDEH.SURVEY_DATE = EXREH.RATE_DATE AND VSDEH.CURRENCY = EXREH.BASE_CURRENCY_ID
)
INNER JOIN qSTAHostCity ON VSURVEYDATA.CITY = qSTAHostCity.HostCity)
WHERE (
v.SURVEY_DATE = [Survey Date]
AND b.LINE_OF_BUSINESS_ID='ICOL'
AND b.BASKET_ID= [Basket ID]
AND ex.HOST_CURRENCY_ID='USD'
AND ex.RATE_SET_ID=' ')
GROUP BY v.CITY, v.CURRENCY ORDER BY v.CITY