SQL: Client Session Duration Report

Company: Expedia

Difficulty: medium

Problem Statement

SQL: Client Session Duration Report Create a report showing the total duration of user sessions for each city. Your result should include: - City name - Total session duration (the sum of all user session durations in that city) Requirements: - Report **every** city, including a city that has no clients or whose clients have no sessions. Such a city has a total session duration of `0`. - Sort results in ascending order by total duration. - If two cities have the same total duration, sort those cities by city name in ascending (A to Z) order. Schema There are 3 tables: `CITIES`, `CLIENTS`, and `SESSIONS`. ### CITIES | Name | Type | Description | |---|---|---| | `id` | String | The assigned ID to the city presented as 32 character UUID. | | `name` | String | The name of the city. | ### CLIENTS | Name | Type | Description | |---|---|---| | `id` | String | The assigned ID to the user presented as 32 character UUID. | | `city_id` | String | The id of the city in which this user resides. | |