子查询返回多行


sub query return more than one row

 select id, first_name, family_name, eq_id,
        date_of_birth, gender, indigenous, eal_d,
        atsi, icp, disability_category,
        (select raw_score
         from path_maths_term0 as T0
         where T0.eq_id=S.eq_id and year=2011
        ) as raw_score_2011term1,
       (select raw_score 
        from path_maths_term0 as T0
        where T0.eq_id=S.eq_id and year=2011
       ) as raw_score_2011term1,
       (select scale_score 
        from path_maths_term0 as T0
        where T0.eq_id=S.eq_id and year=2011
       ) as scale_score_2011term1,
       (select percentile 
        from path_maths_term0 as T0
        where T0.eq_id=S.eq_id and year=2011
       ) as percentile_2011term1,
       (select stanine 
        from path_maths_term0 as T0
        where T0.eq_id=S.eq_id and year=2011 
      ) as stanine_2011term1,
      class 
      from student_details as S
      where S.school_id ="SCH00001" and S.class = " 5B"

在子查询(如)中使用LIMIT 1

select raw_score from path_maths_term0 as T0 where T0.eq_id=S.eq_id and year=2011 LIMIT 1

试试这个

select id, first_name, family_name, eq_id, date_of_birth, gender, indigenous, eal_d, atsi, icp, disability_category,
(select raw_score from path_maths_term0 as T0 where T0.eq_id=S.eq_id and T0.year=2011 ) as raw_score_2011term1,
(select scale_score from path_maths_term0 as T0 where T0.eq_id=S.eq_id and T0.year=2011 ) as scale_score_2011term1,
(select percentile from path_maths_term0 as T0 where T0.eq_id=S.eq_id and T0.year=2011 ) as percentile_2011term1,
(select stanine from path_maths_term0 as T0 where T0.eq_id=S.eq_id and T0.year=2011 ) as stanine_2011term1,
class from student_details as S
 where S.school_id ="SCH00001" and S.class = " 5B"