I'm trying to combine 2 queries to a sql-server pass-through query (PTQ). Both queries, when coded separately in Access, work. When combining these Access codes to one query, it still works in Access. But when I format the field names to T-sql, and try to run as a PTQ, I get a syntax error near "GROUP". When I delete this "GROUP BY" line, I get a syntax error near ";".
SELECT jaar,
maand,
wicode,
pg_intern_code,
pg_kriss_code,
pg_kriss_naam,
Count(pc0517.dbo.resul.klavnr) AS AantalVanKLAVNR
FROM (SELECT Year(pc0517.dbo.resul.created) AS JAAR,
Month(pc0517.dbo.resul.created) AS MAAND,
pc0517.dbo.resul.wicode,
dbo.tblproductgroep_intern.pg_intern_code,
dbo.tblproductgroep_kriss.pg_kriss_code,
dbo.tblproductgroep_kriss.pg_kriss_naam,
pc0517.dbo.resul.klavnr
FROM (dbo.tblproductgroep_kriss
INNER JOIN (dbo.tblproductgroep_intern
INNER JOIN dbo.tblrobbe_pg
ON dbo.tblproductgroep_intern.pg_intern_id =
dbo.tblrobbe_pg.pg_code_intern_id)
ON dbo.tblproductgroep_kriss.pg_kriss_id =
dbo.tblrobbe_pg.pg_code_kriss_id)
INNER JOIN pc0517.dbo.resul
ON dbo.tblrobbe_pg.robbe_pg_naam =
pc0517.dbo.resul.prcode
WHERE ( ( Year(pc0517.dbo.resul.created) = 2012 )
AND ( pc0517.dbo.resul.kanaal = "gg" ) ))
GROUP BY jaar,
maand,
wicode,
pg_intern_code,
pg_kriss_code,
pg_kriss_naam;
Other PTQ's on the same database (even combined with the PC0517 database), work without any glitch, but I'm totally new to SQL-server, so I don't know all the conventions yet, and am probably overlooking something basic...
TIA