Let’s say you have the following table called votes that keeps track of how people voted and you want a query to count the number of votes for you instead of having to loop through all the rows with a counter in PHP.
| person | vote |
|---|---|
| obama | yes |
| mccain | no |
| obama | yes |
| obama | no |
| mccain | yes |
| obama | yes |
| obama | yes |
| obama | no |
| mccain | no |