Thread: Country count
View Single Post
Old 12-01-2012, 10:03 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,187
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
*MAYBE* you are after this?
Code:
SELECT S.country, COUNT(  DISTINCT S.minid ) AS theCount
FROM (
    SELECT country, name, MIN(id) AS minid
    FROM names
    GROUP BY country, name 
    ) AS S
GROUP BY S.country
ORDER BY S.country
???
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote