|
 |
asp_web_howto thread: SELECT DISTINCT count(*) as CountRecords FROM doesn't work
Message #1 by "Ryan vd Merwe" <ryanvdm@i...> on Wed, 26 Feb 2003 21:21:41 +0200
|
|
Hi
I am trying to count distinct records in a table using
"SELECT DISTINCT COUNT(*) as CountRecords FROM..." this does not select
distinct records and give an incorrect count.
if i leave DISTINCT out it works fine.
any solutions welcome!
thanks
Ryan
Message #2 by kyle.b.willman@u... on Wed, 26 Feb 2003 13:28:22 -0600
|
|
Why would you want to SELECT DISTINCT on *?
Kyle B. Willman
PricewaterhouseCoopers LLP
Office: xxx.xxx.xxxx
Cell: xxx.xxx.xxxx
"Ryan vd Merwe" <ryanvdm@i...>
02/26/2003 01:21 PM
Please respond to "ASP Web HowTo"
To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
Subject: [asp_web_howto] SELECT DISTINCT count(*) as CountRecords FROM doesn't work
Hi
I am trying to count distinct records in a table using
"SELECT DISTINCT COUNT(*) as CountRecords FROM..." this does not select
distinct records and give an incorrect count.
if i leave DISTINCT out it works fine.
any solutions welcome!
thanks
Ryan
_________________________________________________________________
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the material
from any computer.
Message #3 by "Thomas, Charles" <CThomas@D...> on Wed, 26 Feb 2003 14:50:24 -0500
|
|
Try:
SELECT COUNT(DISTINCT <column name>) FROM <table name> as
CountRecords
You cannot use the asterisk (*) with DISTINCT, you have to identify the
actual column you want to count
-Charles Thomas
-----Original Message-----
From: kyle.b.willman@u...
[mailto:kyle.b.willman@u...]
Sent: Wednesday, February 26, 2003 2:28 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: SELECT DISTINCT count(*) as CountRecords
FROM doesn't work
Why would you want to SELECT DISTINCT on *?
Kyle B. Willman
PricewaterhouseCoopers LLP
Office: xxx.xxx.xxxx
Cell: xxx.xxx.xxxx
"Ryan vd Merwe" <ryanvdm@i...>
02/26/2003 01:21 PM
Please respond to "ASP Web HowTo"
To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
Subject: [asp_web_howto] SELECT DISTINCT count(*) as
CountRecords FROM doesn't work
Hi
I am trying to count distinct records in a table using
"SELECT DISTINCT COUNT(*) as CountRecords FROM..." this does not select
distinct records and give an incorrect count.
if i leave DISTINCT out it works fine.
any solutions welcome!
thanks
Ryan
_________________________________________________________________
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the material
from any computer.
Message #4 by "Drew, Ron" <RDrew@B...> on Wed, 26 Feb 2003 14:59:33 -0500
|
|
Can do it with *
You have to specify the column you want the distinct on. If you want a
count rather than the distinct printed do a...
SELECT COUNT(DISTINCT columnname) as CountRecords FROM YOURTABLE
-----Original Message-----
From: Ryan vd Merwe [mailto:ryanvdm@i...]
Sent: Wednesday, February 26, 2003 2:22 PM
To: ASP Web HowTo
Subject: [asp_web_howto] SELECT DISTINCT count(*) as CountRecords FROM
doesn't work
Hi
I am trying to count distinct records in a table using
"SELECT DISTINCT COUNT(*) as CountRecords FROM..." this does not select
distinct records and give an incorrect count.
if i leave DISTINCT out it works fine.
any solutions welcome!
thanks
Ryan
|
|
 |