I have the following database:
And I want to count all the entries with the same teamname
, so that I know how many players are in one team. Then i want to check if the teamsize is all ready the size of the NumbersOfMembers and if not so show me them.
The idea is, that I can see which team is not fully completed.
Fixed and tested version of Dans answer:
SELECT teamname, count(*) AS TeamSize, max(numberOfMembers) AS maxMembers
FROM yourTable
GROUP BY teamname
HAVING TeamSize < maxMembers
But you should normalize your table. No need to repeat the general teamdata and restrictions for every user.
Would Something like this work?
SELECT teamname, count(*) as TeamSize group by teamname having count(*) < numberOfMembers
This is just a theoretical answer, untested.