Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tried my best to understand task #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
38 changes: 38 additions & 0 deletions answer.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
-- TYPE YOUR SQL QUERY BELOW


-- I tried my best to understand the task but couldn't wrap my head around it. Wish there were more explanation

-- PART 1: Create a SQL query that maps out the daily average users before and after the feature change

-- Calculate daily average users before the feature change
SELECT
DATE(date_column) AS date,
AVG(users) AS daily_avg_users_before
FROM
user_activity
WHERE
date_column < 'feature_change_date'
GROUP BY
DATE(date_column)
ORDER BY
DATE(date_column);

-- Calculate daily average users after the feature change
SELECT
DATE(date_column) AS date,
AVG(users) AS daily_avg_users_after
FROM
user_activity
WHERE
date_column >= 'feature_change_date'
GROUP BY
DATE(date_column)
ORDER BY
DATE(date_column);



Expand All @@ -10,4 +38,14 @@



-- Count the number of status changes by card
SELECT
card_id,
COUNT(*) AS num_status_changes
FROM
card_status_changes
GROUP BY
card_id
ORDER BY
num_status_changes DESC;