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
|
1641 Discussions
|
Please Login in order to post a comment
with cte_ank as ( select s.id,name,friend_id from students s inner join friends f on s.id =f.id ) select c.name from cte_ank c inner join students st on c.friend_id =st.id inner join packages p on c.id =p.id inner join packages pk on c.friend_id = pk.id where pk.salary>p.salary order by pk.salary ,c.name ;
with student_names as ( select s.id, s.name, p.salary from students s join packages p on s.id = p.id), best_friends as( select f.id as student_id, s.name as bff_name, s.id as bff_id, p.salary from friends f join students s on f.friend_id = s.id join packages p on f.friend_id = p.id ) select sn.name from student_names sn join best_friends bf on sn.id = bf.student_id where bf.salary > sn.salary order by bf.salary
Complete video solution here - https://www.youtube.com/watch?v=gw7ceFdKkpQ&t=22s