Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / March 2008



Tip: Looking for answers? Try searching our database.

Count DISTINCT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary - 26 Mar 2008 13:51 GMT
Hi,
I am using Access DB, and want to calculate how many member in my db.

MemberID
Alan
Peter
Carlie
Alan
Tam

SQL = "SELECT Count(MemberID) As DDD From Trans"
It returns 5

But I want the answer returns 4 because "Alan" is duplicate, then I use
DISINCT :
SQL = "SELECT Count(DISTINCT MemberID) As DDD From Trans"
it returns rs error

I try the following :
SQL = "SELECT DISTINCT MemberID From Trans" ---- its ok

I also try below :

SQL = "SELECT DISTINCT, Count(MemberID) As DDD From Trans"
SQL = "SELECT Count(MemberID, DISTINCT) As DDD From Trans"
SQL = "SELECT Count(DISTINCT, MemberID) As DDD From Trans".............over
hundred SQL or change the Db to digit, let say, 1;2;3;4;2;5 but no use.

Everything go wrong, I search through the web, many peoples said that it is
possible to use Count DISTINCT, but I really try many times, it is a very
simple DB, what wrong with me, can anyone tell me the that he can.

I really lost, thanks for help
Bob Barrows [MVP] - 26 Mar 2008 14:37 GMT
> Hi,
> I am using Access DB, and want to calculate how many member in my db.
[quoted text clipped - 29 lines]
> is a very simple DB, what wrong with me, can anyone tell me the that
> he can.

It is possible to use Count(Distinct), but not in Access (unless they've
added it to A2007).

What you have to do is use a subquery to retrieve the unique values:

Select Count(*) from (SELECT DISTINCT MemberID From Trans) As q

Signature

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.