3848. Analyze Subscription Conversion
My accepted SQL solution to LeetCode problem 3848, Analyze Subscription Conversion, running in 281ms.
- Difficulty: Medium
- SQL
- Runtime 281ms
- Memory 0.0B
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
SQL
Accepted on LeetCode — runtime 281ms, memory 0.0B, accepted 2025-12-31.
# Write your MySQL query statement below
SELECT
t.user_id,
ROUND(AVG(t.activity_duration), 2) AS trial_avg_duration,
ROUND(AVG(p.activity_duration), 2) AS paid_avg_duration
FROM UserActivity t
JOIN UserActivity p ON t.user_id = p.user_id
WHERE t.activity_type = 'free_trial'
AND p.activity_type = 'paid'
GROUP BY t.user_id
ORDER BY t.user_id;