Medium: Question 8

 avatar
user_0571526250
mysql
2 years ago
308 B
1
Indexable
Never
/* Question 8: Medium */

SELECT STUDENTS.NAME
FROM STUDENTS
JOIN PACKAGES ON STUDENTS.ID = PACKAGES.ID
JOIN FRIENDS ON STUDENTS.ID = FRIENDS.ID
JOIN PACKAGES AS FRIENDS_PACKAGES ON FRIENDS.FRIEND_ID = FRIENDS_PACKAGES.ID
WHERE PACKAGES.SALARY < FRIENDS_PACKAGES.SALARY
ORDER BY FRIENDS_PACKAGES.SALARY ASC;