Practice Interview Questions
| Question | Status |
|---|---|
Your goal is to calculate the total active hours for each user. You should use the start and end times of user sessions, defined by the session state: '1' for session start and '0' for session end.
user_sessions table:
| Column Name | Description |
|---|---|
| customer_id | Customer's unique identifier. |
| state | Session's state (1 for start, 0 for end) |
| timestamp | Timestamp of the session state |
| customer_id | total_hours |
|---|
| c005 | 19 |
| c003 | 12.2 |
| c002 | 15 |
Your goal is to calculate the total active hours for each user. You should use the start and end times of user sessions, defined by the session state: '1' for session start and '0' for session end.
user_sessions table:
| Column Name | Description |
|---|---|
| customer_id | Customer's unique identifier. |
| state | Session's state (1 for start, 0 for end) |
| timestamp | Timestamp of the session state |
| customer_id | total_hours |
|---|---|
| c005 | 19 |
| c003 | 12.2 |
| c002 | 15 |