Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help! Syntax error in From Clause 1

Status
Not open for further replies.

jeppoye

Technical User
Jun 30, 2002
6
GB
I've got this query. It works perfectly fine but as soon as I try to make some changes on the query on my access db it would not let me save. I want to change qry_01_xx_BacklogUnion_New to qry_01_xx_BacklogUnion_New1, both tables have same structure.
It's coming back with 'Syntax error in From Clause'. Please help.


SELECT qry_Reference_WGS_Structure.TERRITORY, qry_Reference_WGS_Structure.IMM, qry_Reference_WGS_Structure.MDUM_DESC AS MDUM, qry_Reference_WGS_Structure.ENGINEER_DESC AS ENGINEER, DISTRIBUTION.DAYS_OVERDUE, DISTRIBUTION.WORK_ORDERS

FROM qry_Reference_WGS_Structure LEFT JOIN [SELECT qry_01_xx_BacklogUnion_New.[Work Group] AS WORK_GROUP, tbl_Distribution_Days.[Distribution of Days Overdue] AS DAYS_OVERDUE, Count(qry_01_xx_BacklogUnion_New.[Work Order No]) AS [WORK_ORDERS]

FROM qry_01_xx_BacklogUnion_New LEFT JOIN tbl_Distribution_Days ON qry_01_xx_BacklogUnion_New.[Days Overdue] = tbl_Distribution_Days.Value

GROUP BY qry_01_xx_BacklogUnion_New.[Work Group], tbl_Distribution_Days.[Distribution of Days Overdue]
]. AS DISTRIBUTION ON qry_Reference_WGS_Structure.WORK_GROUP = DISTRIBUTION.WORK_GROUP;
 
Code:
[COLOR=blue]SELECT[/color] qry_Reference_WGS_Structure.TERRITORY, 
       qry_Reference_WGS_Structure.IMM,
       qry_Reference_WGS_Structure.MDUM_DESC [COLOR=blue]AS[/color] MDUM,
       qry_Reference_WGS_Structure.ENGINEER_DESC [COLOR=blue]AS[/color] ENGINEER,
       DISTRIBUTION.DAYS_OVERDUE,
       DISTRIBUTION.WORK_ORDERS
[COLOR=blue]FROM[/color] qry_Reference_WGS_Structure
[COLOR=#FF00FF]LEFT[/color] [COLOR=blue]JOIN[/color] ([COLOR=blue]SELECT[/color] qry_01_xx_BacklogUnion_New.[[COLOR=blue]Work[/color] [COLOR=blue]Group[/color]] [COLOR=blue]AS[/color] WORK_GROUP,
                  tbl_Distribution_Days.[Distribution [COLOR=blue]of[/color] Days Overdue] [COLOR=blue]AS[/color] DAYS_OVERDUE,
                  [COLOR=#FF00FF]Count[/color](qry_01_xx_BacklogUnion_New.[[COLOR=blue]Work[/color] [COLOR=blue]Order[/color] [COLOR=blue]No[/color]]) [COLOR=blue]AS[/color] [WORK_ORDERS]
           [COLOR=blue]FROM[/color] qry_01_xx_BacklogUnion_New
           [COLOR=#FF00FF]LEFT[/color] [COLOR=blue]JOIN[/color] tbl_Distribution_Days [COLOR=blue]ON[/color] qry_01_xx_BacklogUnion_New.[Days Overdue] = tbl_Distribution_Days.Value
           [COLOR=blue]GROUP[/color] [COLOR=blue]BY[/color] qry_01_xx_BacklogUnion_New.[[COLOR=blue]Work[/color] [COLOR=blue]Group[/color]],
                    tbl_Distribution_Days.[Distribution [COLOR=blue]of[/color] Days Overdue]) [COLOR=blue]AS[/color] DISTRIBUTION
      [COLOR=blue]ON[/color] qry_Reference_WGS_Structure.WORK_GROUP = DISTRIBUTION.WORK_GROUP;

When you need derived tables round them with normal brackets, not with square ones.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top