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 Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

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,102,274
Messages
5,485,784
Members
407,515
Latest member
franjey

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top