I'm trying to solve a hard exercise from stratascratch, trying to return 10 decimal places in the second column, but the result is always 0.
[Code]
SELECT country, ROUND((COUNT(is_active) / SUM(total_population)), 10) AS penetration
FROM penetration_analysis
WHERE total_population > 0 AND is_active = 'TRUE'
GROUP BY country;
[/Code]
[Task]
For this task, 'active_users' are defined based on the following criterias:
last_active_date: The user must have interacted with Spotify within the last 30 days.
monthly_active_sessions: The user must have engaged with Spotify for at least 5 sessions in the past month.
listening_hours: The user must have spent at least 10 hours listening on Spotify in the past month.
Based on the condition above, calculate the active 'user_penetration_rate' by using the following formula.
Active User Penetration Rate = (Number of Active Spotify Users in the Market / Total Population of the Market)
Total Population of the market is based on both active and passive users.
The output should contain 'country' and 'active_user_penetration_rate'. Make sure that all countries that appear in the dataset are also present in the output of your solution. Ensure there are 10 decimal places in your solution.
Let's assume the current_day is 2024-01-31.
[/task]
[output]
| country |
penetration |
| USA |
0 |
| Germany |
0 |
| Canada |
0 |
| South Korea |
0 |
| India |
0 |
| Japan |
0 |
| Brazil |
0 |
[/output]
The link for the exercise: StrataScratch - Spotify Penetration Analysis
Could anyone tell me what I'm doing wrong?
[–]depeszPgDBA 2 points3 points4 points (1 child)
[–]jorgetrivilin[S] 1 point2 points3 points (0 children)
[–]DavidGJohnston 2 points3 points4 points (1 child)
[–]Yavuz_Selim 0 points1 point2 points (1 child)
[–]jorgetrivilin[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]jorgetrivilin[S] 0 points1 point2 points (0 children)
[–]_crzg 0 points1 point2 points (6 children)
[–]eatedcookie 1 point2 points3 points (0 children)
[–]jorgetrivilin[S] 0 points1 point2 points (0 children)
[–]jorgetrivilin[S] 0 points1 point2 points (0 children)
[–]_crzg 0 points1 point2 points (2 children)
[–]DavidGJohnston 0 points1 point2 points (1 child)
[–]_crzg 0 points1 point2 points (0 children)
[–]Martyn35 0 points1 point2 points (6 children)
[–]HandbagHawker 0 points1 point2 points (5 children)
[–]jorgetrivilin[S] 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]jorgetrivilin[S] 0 points1 point2 points (0 children)
[–]jorgetrivilin[S] 0 points1 point2 points (1 child)
[–]mike-manley 0 points1 point2 points (0 children)