25. Re-enrollment Rate Calculator
Beginner Mode
Objective
Write a SQL query to calculate the re-enrollment rate of students based on their consecutive term enrollments. The re-enrollment rate is defined as the percentage of students who have enrolled in two or more consecutive terms.
Additional information
Consecutive terms are identified by increasing term_ids without any gaps.
The result should be rounded to two decimal places.
Output the re-enrollment rate as a percentage.
The
enrollmentstable schema:Column Type student_id INT term_id INT course_id VARCHAR
Examples
Example 1:
Output:
Input:
| enrollments | ||
|---|---|---|
| course_id | student_id | term_id |
| CS101 | 1 | 101 |
| CS102 | 1 | 102 |
| CS103 | 1 | 103 |
| CS101 | 2 | 101 |
| CS103 | 2 | 103 |
| CS101 | 3 | 101 |
| CS101 | 4 | 101 |
| CS102 | 4 | 102 |
| re_enrollment_rate |
|---|
| 50 |
Code Environment
Sign in or try as guest to run your code.
Essential
SQL 0/33
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
Google
Revolut
Accenture
Adobe
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
Uber
X
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
GitLab
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
IBM
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Lyft
Salesforce
GitHub
Bloomberg
Airbnb
Walmart
SAP
HashiCorp
Instacart
Mastercard
Intel
Visa
Tesla