In my table, there are 3 records but only two distinct Articles…
section dimension subsection article
-------- ---------- ----------- --------
finance seasonal tax-season 5-tax-shelters-you-need-to-know
finance featured tax-season 5-tax-shelters-you-need-to-know
finance seasonal tax-season what-is-eftps
How do I write a COUNT query for MySQL that will return “2” instead of “3”?
(The query should be keying off of the “article” column, because the other columns could be anything and are not relevant.)
Thanks,
Debbie
r937
2
SQL COUNT() Function
3 seconds on google, girl
Sorry, I was trying…
SELECT DISTINCT COUNT(article)
Debbie
r937
4
well, you could debug that attempt this way –
COUNT(article) will give you one value, and then DISTINCT will make sure that it’s unique

Hindsight is always 20/20…
I thought maybe I had to use a GROUP BY thingy…
Debbie
select article, count(distinct(article)) from table group by article
r937
7
oh my goodness, jack… no
if you group by article, the result will contain one row per article
guess what the distinct count of articles is gonna be for each article
that’s right… 1
GROUP BY is ~not~ appropriate for this problem
My mistaken, didn’t check the requirement clearly.