One-to-one, one-to-many
One-to-one, one-to-many
You are an analyst at the Brightpath online school. There are three tables in the database: students — one row per student; student_profiles — a profile form, exactly one per student (a one-to-one relationship); enrollments — course sign-ups: a student may have several of them, or none at all (a one-to-many relationship). The curator needs a summary: which plan each student is on and how many courses they attend. Important: the profile form must not multiply a student's rows, and the absence of course sign-ups must not throw the student out of the report.
Return the columns:
- full_name — the student's name;
- plan — the plan from the profile form;
- courses_cnt — the number of course sign-ups (an integer; 0 if there are none).
Sorting: courses_cnt descending, then full_name ascending. Students with no course sign-ups must be present in the result with the value 0.
Exemplo de resposta esperada
É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.
| full_name | plan | courses_cnt |
|---|---|---|
| Chloe Davis | premium | 3 |
| Alice Brown | premium | 2 |
| Emma Fisher | free | 2 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar