DAN212 DAN212 - 4 months ago 21x
SQL Question

SQL - Syntax error (missing operator) in query expression 'SUM(Cost) "Total Cost"'

I can't figure this out. I have used the command below in phpmyadmin with no problems but I create my database in Microsoft Access and suddenly the query has a syntax error. I've checked it over and over and I get the same answer everytime. What am I doing wrong?

SELECT vet_id, Visit_date, SUM(Cost) "Total Cost" FROM medication
GROUP BY vet_id, Visit_date;

SELECT vet_id, Visit_date, SUM(Cost) AS [Total Cost]
FROM medication
GROUP BY vet_id, Visit_date;

Access requires you to include the AS keyword when you alias a field expression.

I enclosed the alias in square brackets. If you use quotes instead ... AS "Total Cost" ... Access will include those quotes in the column header.