Exclude entries from SELECT COUNT
This should do the trick.

SELECT COUNT( * ) AS  `how much` ,  `name` ,  `location` 
FROM  table
WHERE  name NOT IN (SELECT name FROM table WHERE location = 'y')
GROUP BY   `name`
ORDER BY   `name` 


The idea behind this is : we are counting the number of name but we have to exclude rows of name where in ANOTHER row there is location = 'y'.

If you do WHERE location &lt;&gt; 'y', you just exclude the line including location = 'y' but the others rows with location = 'x' are still there and used in count(*).

So, the goal is to exclude ALL names where a minimum of one row has location = 'y'. This is why we do name NOT IN (...).

The part between the brackets select all name where location = 'y'. This outputs all names we want to exclude from our COUNT(*). We just have to exclude all these results from our query.

That's all folks !