So I have these following tables:
1) ADDRESS PERSON_ID | START_DATE | END_DATE | STREET | HOUSE | ROOM | ZIPCODE | CITY
2) IDENTIFIER NR | PERSON_ID | ISSUE_DATE | VALID_UNTIL
3) MARRIAGE WIFE_ID | HUSBAND_ID | START_DATE | END_DATE
4) PERSON ID | FIRST_NAME | LAST_NAME | BIRTHDATE | MOTHER_ID | FATHER_ID
And my task is to calculate the number of people who have all 4 grandparents recorded in the database.
So if I got it right, I have to find all the people in the table where both MOTHER_ID and FATHER_ID are not null, whose MOTHER_ID and FATHER_ID columns are also not null.
What I have for now is:
SELECT COUNT(*)
FROM PERSON
WHERE MOTHER_ID IS NOT NULL AND FATHER_ID IS NOT NULL
which returns the number of people who have both parents recorded in the database and I'm stuck at this point.