Start by clarifying the schema and defining 'average call duration in minutes' as the mean of (end_time - start_time) in minutes per user. Then filter calls to those started in the last 7 days, group by user, compute the average, order descending, and limit to 10.
Pro tip: Mention that you would confirm whether 'last 7 days' means a rolling 7-day window from now or the last 7 complete days, and whether to include calls with null end times or zero duration, as these choices can significantly affect the results.
Ask about the table structure, column names, and definitions of 'call duration' and 'last 7 days'. Confirm whether to include only completed calls and how to handle nulls.
Use a WHERE clause to select calls where start_time is within the last 7 days, e.g., start_time >= CURRENT_DATE - INTERVAL '7 days' or equivalent.
Calculate the duration in minutes for each call, then group by user_id and compute the average duration using AVG().
Order the results by average duration descending and limit to the top 10 users.
Mention potential edge cases like ties, users with very few calls, and timezone considerations, and how you would handle them.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.