count question

A

alex

Hello Experts,

I have a table with four columns and 3000 distinct records.

One of the aforementioned columns is named case_number with many
duplicates in that column.

I created a query to count the number of distinct case_numbers within
the column (something that I do all the time w/ SQL in ORACLE).

E.g.,

select count(distinct(case_number))
from table_1;

Access, however, returns a count of all case_numbers, including
duplicates.
I created this workaround:

SELECT Count(case_number) AS COUNT
FROM [select distinct case_number
FROM table_1]. AS [table_1];

I'm wondering why Access won't conduct a count of distinct records on
a particular row (using the first example). Is there something I'm
doing wrong? Thanks for any help.

alex
 
G

Guest

See if this helps.

SELECT case_number, Count(case_number) As TheCount
FROM table_1
GROUP BY case_number;
 
J

John W. Vinson

Hello Experts,

I have a table with four columns and 3000 distinct records.

One of the aforementioned columns is named case_number with many
duplicates in that column.

I created a query to count the number of distinct case_numbers within
the column (something that I do all the time w/ SQL in ORACLE).

For some reason that I can't understand, JET SQL does not support the very
reasonable Count Distinct syntax. You'll need to base a query on a query:

SELECT Count(*) FROM
(SELECT DISTINCT Case_Number FROM yourtable);

John W. Vinson [MVP]
 
A

alex

For some reason that I can't understand, JET SQL does not support the very
reasonable Count Distinct syntax. You'll need to base a query on a query:

SELECT Count(*) FROM
(SELECT DISTINCT Case_Number FROM yourtable);

John W. Vinson [MVP]

Thank you gentlemen for your help.

alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top