Created
December 5, 2018 18:07
-
-
Save shojibMahabub/42e88e21c23c75a2953005eb68ea3848 to your computer and use it in GitHub Desktop.
database query for problem 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Explanation: | |
-------------- | |
In order to get the result, | |
I joined packages to get student's salaries. and joined friends | |
to get ID. For getting Friends salary I joined Packages once again. | |
Then I compared between salaries to find the students. | |
After that I ordered them by salary. | |
QUERY: | |
--------------- | |
SELECT s.Name FROM Students AS s | |
JOIN Packages AS sp ON s.ID = sp.ID | |
JOIN Friends AS f ON s.ID = f.ID | |
JOIN Packages AS fp ON f.Friend_ID = fp.ID | |
WHERE sp.Salary < fp.Salary | |
ORDER BY fp.Salary; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment