So, I choose the name and a number of sports that this name is associated with, and I need to choose them only when the number of sports achievements is more than 1.
SELECT DISTINCT name AS FullName,
(SELECT COUNT(id) FROM coaches WHERE coaches.name=FullName) AS NrOfSports
FROM coaches WHERE NrOfSports>1
If WHEREdeleted, the query works just fine and displays all the lines, some of which have only "1" as NrOfSports. When I add it to a sentence WHERE, I get an error because it is not recognized. This puzzles me, because if I used it in another column SELECT, it would work fine.
Is there any way to do this? It cannot be software dependent.
source
share