jamiecottonuk
Technical User
HI all,
I have a table called people in my database.
it looks like this
I want to display the distinct name and how many times they are in the table
So like this
Jill - 3
bob - 1
John - 1
How would I go about doing this. I thought maybe something like this but not to sure
I have a table called people in my database.
it looks like this
Code:
+----+------+
| id | name |
+----+------+
| 2 | bob |
| 1 | Jill |
| 3 | Jill |
| 4 | John |
| 5 | Jill |
+----+------+
So like this
Jill - 3
bob - 1
John - 1
How would I go about doing this. I thought maybe something like this but not to sure
Code:
SELECT COUNT(name)
FROM people
WHERE name =
(SELECT DISTINCT name
FROM people);