View Full Version : select count(distinct id)


pasan
04-18-2002, 12:53 PM
how can i count the distinct no of records in access.
say we have values id (1,2,3,2,4,1 )
i wanna get 4 as my answer
but if i write
SELECT COUNT(DISTINCT id) from ...
is giving me an error in access, but works in others..
how can i solve this problem..

Pat Hartman
04-18-2002, 01:00 PM
This shortcut method is not supported by Jet SQL. You need to first get a distinct list of the values before you can count them. Try the following:

Query1:
Select Distinct YourField From YourTable;
Query2:
Select Count(*) From Query1;