Probelm Quering Access Database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, i have a query that works normal from access query window
but when i execute if from my code with cmd.executereader it give me error
"The SELECT statement includes a reserved word or an argument name that is
misspelled or missing, or the punctuation is incorrect."

the query is below, if someone is interested

Thanks in advance!!


SELECT a.MACH AS MACHINE, a.ST AS STATE, ROUND(a.DURATION1/(60*60), 2) AS
DURATION,
ROUND((a.DURATION1/b.DURATION2)*100, 2) AS PERCENTAGE,
a.OCC AS OCCUR, a.YEAR, a.PNUM, a.PERIODSTART, a.PERIODEND
FROM
(SELECT MACHINE AS MACH, STATE AS ST,
SUM(OCCUR) AS OCC,
SUM(DURATION) AS DURATION1,
DATEPART('yyyy', CURDAY) AS YEAR,
DATEPART('m', CURDAY) AS PNUM,
MIN(CURDAY) AS PERIODSTART,
MAX(CURDAY) AS PERIODEND
FROM test_DCXTMP
WHERE CURDAY BETWEEN #2004-3-1# AND #2004-3-15#
AND MACHINE = 'ARS'
GROUP BY MACHINE, STATE, DATEPART('m', CURDAY), DATEPART('yyyy', CURDAY)
) as a
INNER JOIN
(SELECT MACHINE AS M, SUM(DURATION) AS DURATION2,
DATEPART('yyyy', CURDAY) AS YEAR,
DATEPART('m', CURDAY) AS PNUM
FROM test_DCXTMP
WHERE CURDAY BETWEEN #2004-3-1# AND #2004-3-15#
AND MACHINE = 'ARS'
GROUP BY MACHINE, DATEPART('m', CURDAY), DATEPART('yyyy', CURDAY)
) as b
ON a.MACH = b.M AND a.YEAR = b.YEAR AND a.PNUM = b.PNUM
ORDER BY a.YEAR, a.PNUM
 
Saved Access queries that contain VBA functions only execute within
Access, which loads the expression service to process the function.

--Mary
 
Back
Top