The Find Longest Calls interview question is a SQL task. You are given a Calls table containing information about telephone calls, including caller ID, recipient ID, and the duration of the call. Your goal is to identify the top 3 longest calls for each day or globally, depending on the specific variation. Usually, you need to return the contact names and the duration formatted into "HH:MM:SS".
IBM and other data-heavy companies use this to test proficiency in SQL Window Functions and formatting. It evaluates your ability to rank data within groups and your knowledge of time-to-string conversion. it's a practical reporting task that tests if you can handle aggregations and formatting simultaneously in a relational database context.
The problem uses SQL Ranking and Formatting.
RANK(), DENSE_RANK(), or ROW_NUMBER() over a window partitioned by the grouping criteria (like date) and ordered by duration descending.duration / 3600(duration % 3600) / 60duration % 60Users table if names are required instead of just IDs.Practice using LPAD() or RIGHT('00' + val, 2) to handle time formatting in SQL. Being able to correctly convert raw seconds into a human-readable format is a vital skill for anyone working with timestamped data.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Activity Participants | Medium | Solve | |
| Active Businesses | Medium | Solve | |
| Active Users | Medium | Solve | |
| All People Report to the Given Manager | Medium | Solve | |
| All the Pairs With the Maximum Number of Common Followers | Medium | Solve |