From 2c041dcad561201c0d434fc90167a70b9ae7bf3e Mon Sep 17 00:00:00 2001 From: Haswatha Sridharan Date: Tue, 10 Jun 2025 18:29:45 -0500 Subject: [PATCH] Mock_SQL1 Completed --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65489fb..a6015b0 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file