• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

SELECT COUNT(DISTINCT Field) ... Not Working... What am I missing?

Greetings All!

Here is the deal, I am trying to Count all of the unqiue groups in a table. I thought it should be as easy as :

SELECT COUNT(DISTINCT tGroup)as 'CNT' From Terms

I have checked a few other posts on here to confirm my syntax... unless I am overlooking a detail, it should be right.
This is the error I receive:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'COUNT(DISTINCT tGroup)'.

/inc/functions/dbConn.asp, line 10

Any ideas?
0
intreeg
Asked:
intreeg
  • 2
1 Solution
 
tusharashahCommented:
Try using this Query:

SELECT COUNT(*) as 'CNT'
FROM (SELECT DISTINCT tGroup FROM Terms)

-tushar
0
 
intreegAuthor Commented:
Beautiful!!!!
BTW: I made an error to begin with there should be no ' ' around CNT ... just for reference for anyone looking for this solution!

Good Job tushar!
0
 
tusharashahCommented:
Nice to have you going!

Thanks for A

-tusahr
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now