日期:2014-05-17 浏览次数:20808 次
select t.ID,
t.SCHOOL_NAME,
(select count(*) from T_STUDENT where SCHOOL_ID = t.ID and ISACTIVE = 1) STUCOUNT,
(select count(*) from (select distinct STUDENT_ID from T_BUSINESS where SCHOOL_ID = t.ID and (STATUS = 1 or STATUS = 2))) BIZCOUNT
from (select tb.*, rownum rn from T_SCHOOL tb where ISACTIVE = 1 and rownum <= 20) t
where rn > 0 order by CITY, REGIONNAME, SCHOOL_NAME;
select t.ID,
t.SCHOOL_NAME,
(select count(*) from T_STUDENT where SCHOOL_ID = t.ID and ISACTIVE = 1) STUCOUNT,
(select count(distinct STUDENT_ID) from T_BUSINESS where SCHOOL_ID = t.ID and (STATUS = 1 or STATUS = 2)) BIZCOUNT
from (select tb.*, rownum rn from T_SCHOOL tb where ISACTIVE = 1 and rownum <= 20) t
where rn > 0 order by CITY, REGIONNAME, SCHOOL_NAME;