PC Review


Reply
Thread Tools Rate Thread

count question

 
 
alex
Guest
Posts: n/a
 
      25th Oct 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVycnkgV2hpdHRsZQ==?=
Guest
Posts: n/a
 
      25th Oct 2007
See if this helps.

SELECT case_number, Count(case_number) As TheCount
FROM table_1
GROUP BY case_number;
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"alex" wrote:

> 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
>
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      25th Oct 2007
On Thu, 25 Oct 2007 11:18:29 -0700, alex <(E-Mail Removed)> wrote:

>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]
 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      26th Oct 2007
On Oct 25, 5:33 pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Thu, 25 Oct 2007 11:18:29 -0700, alex <sql_...@yahoo.com> wrote:
> >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]


Thank you gentlemen for your help.

alex

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
count duplicats, display incremental count, restart count at changein value JenIT Microsoft Excel Programming 2 24th Aug 2010 09:10 PM
COUNT QUESTION JAY Microsoft Excel Misc 2 30th Sep 2008 04:59 PM
Count Question =?Utf-8?B?RGV4dGVyZ2lpaQ==?= Microsoft Access Queries 5 4th Aug 2007 10:06 PM
Count If question =?Utf-8?B?RGVuaXNl?= Microsoft Excel Misc 3 16th Aug 2005 09:37 PM
Count If Question =?Utf-8?B?TmV3Ymll?= Microsoft Excel Worksheet Functions 7 19th Apr 2004 11:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:33 PM.