tags:

views:

58

answers:

2
SELECT DISTINCTROW [OEE/A Query].Press, Sum([OEE/A Query].[SumOfLabor Hours]) AS [Sum Of SumOfLabor Hours], Sum([OEE/A Query].[SumOfGood Pieces]) AS [Sum Of SumOfGood Pieces], Sum([OEE/A Query].[Scrap Pieces]) AS [SumOfScrap Pieces], Sum([OEE/A Query].[SumOfMachine Hours]) AS [SumOfSumOfMachine Hours], Sum([OEE/A Query].[Total Parts Hours Earned]) AS [SumOfTotal Parts Hours Earned], Sum([OEE/A Query].[Standard Pcs Expected]) AS [Stand Pcs Expected]
FROM [OEE/A Query]
GROUP BY [OEE/A Query].Press;
SELECT Sum(Sort)+Sum(Straighten)+Sum(Shine)+Sum(Standardize)+Sum(Sustain) AS total
FROM [Shift Report Table];

When i run this code, it produces an error which is "Characters found after end of SQL statement". So how do i adjust this code to avoid any errors?

A: 

I'm not sure, but I don't think you need the ; character. What happens when you take them out?

Hogan
The ';' is part of the standard. Optional in older products, but the option leaving off of the ';' is being deprecated in SQL Server 2008. It's good form to just go ahead and get used to using it now.
Brian Knoblauch
If i take the ; character out after Press and after Table] in the end i get a syntax error and it highlights the word SELECT when i hit ok.
Jeff Anderson
@Brian: I did not know that, what standard is `;` in?
Hogan
@Hogan - "SQL statements also include the semicolon (";") statement terminator. Though not required on every platform, it is defined as a standard part of the SQL grammar." - from http://en.wikipedia.org/wiki/SQL
Brian Knoblauch
@Brian - I won't edit wikipedia to prove my point, but it is not the most reliable source. Sadly this is the state of SQL where the standards are pay only.
Hogan
+4  A: 

Access queries don't allow you to have two SELECT queries in the same window. So you have to separate your two queries.

I'm assuming you are working in the Access query design window

hawbsl
Yes i am working in the query SQL window
Jeff Anderson
Have you tried the queries one at a time?
hawbsl
Are the paremeters added in the query section or the report section?Do you not add them to the SQL code?
Jeff Anderson
@Jeff Anderson: You seem to be missing the key point -- Access/Jet/ACE can't process more than one SQL statement at a time. You have two, and the error message is telling you that everything after the first ";" is invalid, BECAUSE IT IS.
David-W-Fenton