Question: SELECT GP 1 . Name AS GrandFather, GP 2 . Name AS GrandMother, Grandson.Name AS Grandson FROM Parent Pa 1 JOIN Parent Pa 2 ON

SELECT GP1.Name AS GrandFather, GP2.Name AS GrandMother, Grandson.Name AS Grandson
FROM Parent Pa1
JOIN Parent Pa2 ON Pa1.ChildID = Pa2.ParentID AND Pa1.ParentID != Pa2.ParentID
JOIN Person GP1 ON Pa1.ParentID = GP1.PersonID
JOIN Person GP2 ON Pa1.ParentID = GP2.PersonID
JOIN Person Grandson ON Pa2.ChildID = Grandson.PersonID
WHERE GP1.Name < GP2.Name, GP1.Gender ='M' AND GP2.Gender ='F';
How do I get the SQL Query to return the table with Grandfathers and Grandmothers in their own columns and show the grandsons ??

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!