From db8043995d2678870b4eb5d1ab378b562846c535 Mon Sep 17 00:00:00 2001 From: akanksha-vishwak Date: Mon, 2 Jun 2025 17:33:25 -0400 Subject: [PATCH] solution to problem 1, 3 --- 01-ConsecutiveNumbers.sql | 5 +++++ 03-UserActivity.sql | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 01-ConsecutiveNumbers.sql create mode 100644 03-UserActivity.sql diff --git a/01-ConsecutiveNumbers.sql b/01-ConsecutiveNumbers.sql new file mode 100644 index 0000000..993884f --- /dev/null +++ b/01-ConsecutiveNumbers.sql @@ -0,0 +1,5 @@ +-- Problem 1 : Consecutive Numbers (https://leetcode.com/problems/consecutive-numbers/) + +select distinct l3.num as 'ConsecutiveNums' from logs l1, logs l2, logs l3 +where l1.id = l2.id -1 and l2.id = l3.id -1 and +l1.num=l2.num and l2.num=l3.num \ No newline at end of file diff --git a/03-UserActivity.sql b/03-UserActivity.sql new file mode 100644 index 0000000..3798e6d --- /dev/null +++ b/03-UserActivity.sql @@ -0,0 +1,6 @@ +-- Problem 3 :User Activity (https://leetcode.com/problems/user-activity-for-the-past-30-days-i/ ) + +select distinct activity_date as 'day', count(distinct user_id) as active_users +from activity +where activity_date >= '2019-06-28' and activity_date <= '2019-07-27' +group by activity_date \ No newline at end of file