JCWEBHOST
asked on
sql DISTINCT
hey guy i need to count the number of DISTINCT
but this statement
SELECT DISTINCT description, COUNT(DISTINCT description) from groupon GROUP BY description
output
description Column1
d 1
i have d description in my table
but this statement
SELECT DISTINCT description, COUNT(DISTINCT description) from groupon GROUP BY description
output
description Column1
d 1
i have d description in my table
SELECT description, COUNT(DISTINCT description) from groupon GROUP BY description
SELECT COUNT(description) , description FROM GROUPON GROUP BY description
Besides the first DISTINCT is superfluous (group-by columns are always distinct) I cannot see something wrong. Try
select distinct description from groupon;
select description, count(*), count(description), count(distinct description) from groupon group by description;
to compare the results.
You dont need to use distinct, you are already grouping with the field
If you simply need to display the distinct descriptions
select description
from groupon
group by description
or if you want to use distinct
select distinct description
from groupon
select description
from groupon
group by description
or if you want to use distinct
select distinct description
from groupon
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT count(DISTINCT description) FROM groupon GROUP BY description;