Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Mock_SQL
1 Problem 1 : Top Travellers (https://leetcode.com/problems/top-travellers/)

Please submit the interview problems posted in slack channel here. The problems and statements are intentionally not shown here so that students are not able to see them in advance
Solution:
Select U.name, ifnull(sum(R.distance),0) as travelled_distance
from Users U
left join Rides R
on U.id = R.user_id
group by U.id
order by travelled_distance desc, name

1 Problem 1 : Apples & Oranges (https://leetcode.com/problems/apples-oranges/)

Solution:
Select a.sale_date, sum(a.sold_num - b.sold_num) as diff
from Sales a
join Sales b
on a.sale_date = b.sale_date
where a.fruit in ('apples') and b.fruit in ('oranges')
group by a.sale_date
order by a.sale_date