ODBC error when executing query using MS Access 2013 agaist SQL 2008 using ODBC client 10

Hello I have the statement below that works fine again MS Access table, however it gives me the attached error message when running against a linked ODBC connection to SQL of the same table. How can I fix this? Error message
SELECT BMPDATA.Battery, Count(BMPDATA.Battery) AS Deployments, Count([NoSample]="Dead Battery") AS Dead
FROM BMPDATA
GROUP BY BMPDATA.Battery;
Cobra967Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
This may have this in mind:

    Sum(Abs([NoSample]="Dead Battery"))

/gustav
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
That's a syntax error and not an ODBC error.

T-SQL
SELECT Battery, Count(Battery) AS Deployments, Count(CASE[NoSample] WHEN 'Dead Battery' THEN 1 ELSE 0 END) AS Dead
FROM BMPDATA
GROUP BY Battery

Open in new window


I'll not comment on Access SQL, as my skills are a little rusty there.
0
Cobra967Author Commented:
Thank you Jim, but the count of dead battery is the same as total deployment which is not correct. I am try to determine how many time a battery was used and how many time the device did not works because the battery was dead. The field NoSample will use have the word Dead Battery when the battery was the cause of no data collection. The code I provided is from MS Access not SQL.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Cobra967Author Commented:
It seems to work in SQL if I use: COUNT(CASE WHEN [NoSample] = 'Dead Battery' THEN 1 ELSE NULL END
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Typo in my first post,Count should have been Sum
SELECT Battery, Count(Battery) AS Deployments, Sum(CASE[NoSample] WHEN 'Dead Battery' THEN 1 ELSE 0 END) AS Dead
FROM BMPDATA
GROUP BY Battery

Open in new window


>It seems to work in SQL if I use: COUNT(CASE WHEN [NoSample] = 'Dead Battery' THEN 1 ELSE NULL END
S'pose it would, as it's not counting NULLs..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.