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 YoungerSibling and OlderSibling (use column YearBorn 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 YoungerSibling,
  Os.Name AS OlderSibling
FROM Person AS Ys
JOIN Person AS Os
  ON Ys.MotherId = Os.MotherId
  AND Ys.FatherId = Os.FatherId
WHERE Ys.YearBorn > Os.YearBorn