Facebook
From Mustard Partdridge, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 40
  1. SELECT name
  2. FROM(
  3.     SELECT y.ID, y.Name, y.Salary as Salary, y.Friend_ID, Packages.Salary as Friend_Salary
  4.     FROM(
  5.         SELECT Friends.ID, Name, Salary, Friends.Friend_ID
  6.         FROM(
  7.             SELECT Students.ID, Name, Salary
  8.             FROM Students
  9.             INNER JOIN Packages
  10.             ON Students.ID = Packages.ID
  11.         )as x
  12.         INNER JOIN Friends
  13.         ON Friends.ID = x.ID
  14.     )as y
  15.     INNER JOIN Packages
  16.     ON y.Friend_ID = Packages.ID
  17. )as z
  18. WHERE Friend_Salary > Salary
  19. ORDER BY Friend_Salary