We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- SQL
- Advanced Join
- Placements
- Discussions
Placements
Placements
Sort by
recency
|
1923 Discussions
|
Please Login in order to post a comment
MySQL - simplest solution using join
WITH CTESAL AS (SELECT S.NAME AS NAME,P.SALARY AS MySAL,F.FRIEND_ID,PA.SALARY AS FRSAL FROM STUDENTS S JOIN PACKAGES P ON S.ID = P.ID JOIN FRIENDS F ON F.ID= S.ID JOIN PACKAGES PA ON F.FRIEND_ID = PA.ID WHERE P.SALARY < PA.SALARY ORDER BY PA.SALARY ASC) SELECT NAME FROM CTESAL
with cte_stu as( select F.ID,s.name,P.Salary from Friends F join Packages P on F.ID=P.ID join Students s on F.ID=s.ID),
Select st.name from
cte_stu St join Friends F on ST.ID=F.ID join cte_fri fr on fr.Friend_ID=F.Friend_ID where Fr.salary > st.Salary order by fr.salary
Select name from (SELECT l.id,l.name as name,f.friend_id,p.salary from Students l Join Friends f on l.id = f.id JOIN Packages p on f.id = p.id where p.salary < (Select salary from Packages where id = f.friend_id) order by (Select salary from Packages where id = f.friend_id)) t;