Solved

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

Posted on 2004-10-07
3
528 Views
Last Modified: 2008-01-16
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
Comment
Question by:intreeg
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
tusharashah earned 500 total points
Comment Utility
Try using this Query:

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

-tushar
0
 
LVL 5

Author Comment

by:intreeg
Comment Utility
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
 
LVL 18

Expert Comment

by:tusharashah
Comment Utility
Nice to have you going!

Thanks for A

-tusahr
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now