Company: IBM
Difficulty: medium
Problem Description An analyst in the Trust and Security department of InternetBank needs a report detailing the total duration of user sessions grouped by city. Write a query to retrieve the city names along with the total session duration for each city. The total session duration is the sum of all individual user session durations associated with that city. Schema Table: cities Column Name Data Type Description id INT Primary key for the city name VARCHAR The name of the city Table: user_sessions Column Name Data Type Description id INT Primary key for the session city_id INT Foreign key referencing cities.id duration INT The duration of the user session (e.g., in seconds) Required Output The output must contain exactly two columns structured and aliased as follows: name (from the cities table) duration (the calculated total session duration) The result set must be sorted in ascending order by duration . If multiple cities have the same total duration, order them alphabetically by na