1142. User Activity for the Past 30 Days II

https://leetcode.com/problems/user-activity-for-the-past-30-days-ii

Description

Table: Activity


+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| user\_id       | int     |
| session\_id    | int     |
| activity\_date | date    |
| activity\_type | enum    |
+---------------+---------+
There is no primary key for this table, it may have duplicate rows.
The activity\_type column is an ENUM of type ('open\_session', 'end\_session', 'scroll\_down', 'send\_message').
The table shows the user activities for a social media website.
Note that each session belongs to exactly one user.

Write an SQL query to find the average number of sessions per user for a period of 30 days ending 2019-07-27 inclusively, rounded to 2 decimal places. The sessions we want to count for a user are those with at least one activity in that time period.

The query result format is in the following example:

ac

Last updated

Was this helpful?