Depression is associated with lower educational attainment, but there has been little investigation of long-term educational trajectories in large cohorts with diagnosed depression.To describe the educational attainment trajectories of children with a depression diagnosis in secondary care, and to investigate whether these trajectories vary by sociodemographic characteristics.We identified new referrals to South London and Maudsley's NHS Foundation Trust between 2007 and 2013 who received a depression diagnosis at under 18 years old. Linking their health records to the National Pupil Database, we standardised their performance on three assessments (typically undertaken at ages 6-7 years (school Year 2), 10-11 (Year 6) and 15-16 (Year 11)) relative to the local reference population in each academic year. We used mixed models for repeated measures to estimate attainment trajectories.In our sample of 1492 children, the median age at depression diagnosis was 15 years (interquartile range = 14-16). Their attainment showed a decline between school Years 6 and 11. Attainment was consistently lower among males and those eligible for free school meals. Black ethnic groups also showed lower attainment than White ethnic groups between Years 2 and 6, but showed a less pronounced drop in attainment at Year 11.Those who receive a depression diagnosis during their school career show a drop in attainment in Year 11. Although this pattern was seen among multiple sociodemographic groups, gender, ethnicity and socioeconomic status predict more vulnerable subgroups within this clinical population who might benefit from additional educational support or more intensive treatment.