Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dictionary database
Summary
11. Person table – exercise 2

Instruction

Okay, try this one!

Exercise

List all pairs of full siblings. Full siblings are people who have the same mother and the same father. Name the columns with sibling names younger_sibling and older_sibling (use column year_born to identify who is younger).

You can assume that in our database no two siblings were born in the same year and there are no more than two siblings per family.

Stuck? Here's a hint!

Type:

SELECT
  ys.name AS younger_sibling,
  os.name AS older_sibling
FROM person AS ys
JOIN person AS os
  ON ys.mother_id = os.mother_id AND ys.father_id = os.father_id
WHERE ys.year_born > os.year_born