BackgroundChronic ill health can affect children's educational and health outcomes. Previous studies have reported poorer school outcomes among children with diabetes, asthma, epilepsy, attention deficit hyperactivity disorder (ADHD), and depression; however, many have limitations, very few have analysed multiple outcomes or population-wide data, and literature in Scotland and the UK is scarce. We aimed to identify children prescribed medication for these chronic medical conditions and investigate their educational and health outcomes compared with their peers. MethodsWe retrospectively linked Scotland-wide education records for children attending primary and secondary schools in Scotland between 2009 and 2013 to prescribing data, acute and psychiatric hospital admissions, maternity records, and deaths. School absenteeism, exclusion, and special educational need were analysed annually using generalised estimating equations. Academic attainment was analysed using generalised ordinal logistic regression and unemployment with binomial logistic regression. All-cause hospitalisation and mortality were analysed using Cox proportional hazards or Poisson piecewise regression. Analyses were restricted to singleton children born in Scotland and adjusted for sociodemographic or maternity factors and comorbid conditions Findings766 244 schoolchildren were included in the analyses. All conditions were associated with increased school absenteeism (diabetes incidence rate ratio [IRR] 1·34, asthma 1·25, epilepsy 1·50, ADHD 1·18, depression 1·95), special educational need (diabetes odds ratio [OR] 2·45, asthma 1·28, epilepsy 10·11, ADHD 8·77, depression 2·24], and all-cause hospitalisation (diabetes hazard ratio [HR] 3·97, asthma 1·69, epilepsy 3·72, ADHD 1·33, depression 2·56). All, excluding diabetes, were associated with poorer academic attainment (asthma OR 1·11, epilepsy 4·07, ADHD 3·64, depression 3·44] and all, excluding ADHD, were associated with increased all-cause mortality [diabetes HR 3·84, asthma 1·77, epilepsy 24·77, depression 6·21]. ADHD (IRR 5·82) and depression (1·65) were associated with increased exclusion from school, whereas epilepsy (OR 1·99), ADHD (1.42), and depression (1·98) were associated with subsequent unemployment. InterpretationIn addition to poorer health outcomes, schoolchildren with these chronic medical conditions have significant educational disadvantage compared with their peers. Interventions and further understanding of the relationships between health and education among children with these conditions is required. FundingHealth Data Research UK