This is a premium problem. We're working on making it available for free soon.
Explore Free ProblemsSolutions for this premium problem will be available for free soon.
Browse Free ProblemsWatch expert explanations and walkthroughs
Practice problems asked by these companies to ace your technical interviews.
Explore More ProblemsJot down your thoughts, approach, and key learnings
Yes, SQL aggregation and analytics-style queries like this are commonly asked in technical interviews. Companies often test a candidate’s ability to compute metrics using filtering, grouping, and distinct counts.
The optimal approach filters activity records within the last 30 days and uses SQL aggregation. Count distinct session IDs and distinct users, then divide the two values to compute the average sessions per user.
Common SQL functions include COUNT(DISTINCT ...), DATE_SUB, and conditional functions like IFNULL or COALESCE. These help filter the date range and safely compute averages when no records exist.
The key concept is SQL aggregation rather than traditional data structures. Understanding how to use GROUP BY logic and DISTINCT counting is essential for solving the problem efficiently.