If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > MS ACCESS COUNT function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-18-02, 04:28
alex_db alex_db is offline
Registered User
 
Join Date: Oct 2002
Posts: 16
MS ACCESS COUNT function

When I used Count () function to count distinct rows in MS Access, I got the error for the syntax of this Count expression.

Here is the query:

SELECT ColA, COUNT(DISTINCT ColB)
FROM TAB1
GROUP BY ColA

I issued the above query in DB2 and there is no error. Anyone has any idea why Access complains expression syntax of the above query?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-21-02, 14:57
ArsenGutsal ArsenGutsal is offline
Registered User
 
Join Date: Dec 2002
Posts: 1
Re: MS ACCESS COUNT function

You can't use DISTINCT keyword here.

Quote:
Originally posted by alex_db
When I used Count () function to count distinct rows in MS Access, I got the error for the syntax of this Count expression.

Here is the query:

SELECT ColA, COUNT(DISTINCT ColB)
FROM TAB1
GROUP BY ColA

I issued the above query in DB2 and there is no error. Anyone has any idea why Access complains expression syntax of the above query?

Thanks!
Reply With Quote
  #3 (permalink)  
Old 12-21-02, 23:14
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
if you really need it, alex, there is a way to do this with a microsoft access "view" i.e. query of query

however, you need to confirm that you really want select colA, count(distinct colB) rather than select colA, count(colB) because they are different

what you do is define a query like select distinct colA, colB and then save this, after which you can do select colA, count(colB) from savedquery

if this isn't clear, tell me your columns and i'll rework the queries


rudy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On