MS Query Incorrect syntax near the keyword 'AS'

Jubert

New Member
Joined
Jun 1, 2016
Messages
28
I am trying to amend SQL in MS query and the error "Incorrect Syntax near the keyword AS" is being returned when I submit this code. What is wrong with the AS in this case? I've searched similar threads and tried to apply advice but still haven't managed to get it to work.
Thanks in advance

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">SELECT
ARM_GP_GROUPINGS.GrpCode,
arm_cc_group_names.cc_name,
CST_COSTCENTRE.CC_CODE,
CST_COSTCENTRE.CC_NAME,
CST_COSTCENTRE.CC_LEVELPOINTER,
CST_COSTHEADER.CH_CODE,
CST_COSTHEADER.CH_NAME,
CST_COSTHEADER.CH_USER3,
CST_COSTHEADER.CH_USER4,
CST_DETAIL.CT_NETT,
CST_DETAIL.CT_SORTTYPE,
CST_DETAIL.CT_PERIODNUMBR,
CST_DETAIL.CT_YEAR,
SL_ACCOUNTS.CUCODE,
SL_ACCOUNTS.CUNAME,
CST_COSTHEADER.CH_CODE

FROM
MWLIVE.dbo.CST_DETAIL CST_DETAIL
AS Detail
INNER
JOIN MWLIVE.dbo.CST_COSTCENTRE CST_COSTCENTRE
AS Costcentre
ON Costcentre.CC_CODE = Detail.CT_COSTCENTRE
INNER
JOIN MWLIVE.dbo.CST_COSTHEADER CST_COSTHEADER
AS Costheader
ON Costheader.CH_CODE = Costcentre.CC_COPYHEADER
LEFT OUTER
JOIN Costcentre
ON Costcentre.CC_LEVELPOINTER = MWLIVE.dbo.arm_cc_group_namesarm_cc_group_names.cc_levelpointer
LEFT OUTER
JOIN Costheader
ON Costheader.CH_ACCOUNT = MWLIVE.dbo.SL_ACCOUNTS SL_ACCOUNTS.CUCODE
INNER
JOIN Costheader
ON Costheader.CH_CODE = MWLIVE.dbo.ARM_GP_GROUPINGS ARM_GP_GROUPINGS.ch_code

WHERE ((CST_DETAIL.CT_YEAR='C') AND (CST_DETAIL.CT_PERIODNUMBR=1))</code>
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

sericom

Well-known Member
Joined
Jan 19, 2006
Messages
905
Your table aliasing doesn't look right

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">FROM
MWLIVE.dbo.CST_DETAIL Detail
INNER
JOIN MWLIVE.dbo.CST_COSTCENTRE Costcentre
ON Costcentre.CC_CODE = Detail.CT_COSTCENTRE
INNER
JOIN MWLIVE.dbo.CST_COSTHEADER Costheader
ON Costheader.CH_CODE = Costcentre.CC_COPYHEADER</code>
 

Watch MrExcel Video

Forum statistics

Threads
1,099,045
Messages
5,466,219
Members
406,473
Latest member
Dunno123

This Week's Hot Topics

Top