Return to exercises
Show the number of children per family: name of father, name of mother, number of children:
| FatherName | MotherName | ChildrenCount |
| Marcel | Gitte | 2 |
| Leon | Inge | 1 |
Show the answer
SELECT
(SELECT Name FROM people p2 WHERE p2.Id = pc.Father) AS FatherName,
(SELECT Name FROM people p3 WHERE p3.Id = pc.Mother) AS MotherName,
COUNT(*) AS ChildrenCount
FROM parentchild pc
GROUP BY pc.Father, pc.Mother
Tables:

cities| id | City |
|---|
| 2 | Eindhoven |
| 1 | Tilburg |
| 3 | Veldhoven |
| 4 | Den Bosch |
parentchild| Child | Father | Mother |
|---|
| 6 | 1 | 3 |
| 7 | 1 | 3 |
| 8 | 4 | 5 |
people| Id | Name | DOB | City |
|---|
| 1 | Marcel | 0000-00-00 | 1 |
| 2 | Peter | 0000-00-00 | 2 |
| 3 | Gitte | 0000-00-00 | 1 |
| 4 | Leon | 0000-00-00 | 2 |
| 5 | Inge | 0000-00-00 | 3 |
| 6 | Sienna | 1990-01-01 | 1 |
| 7 | Thomas | 1992-01-01 | 1 |
| 8 | Bas | 1994-01-01 | 2 |