select
t.schoolid,t.id,t.photoname
from
T_SchoolPhoto t
where
not exists(select 1 from T_SchoolPhoto where id>t.id and schoolid=t.schoolid)
select
t.schoolid,t.id,t.photoname
from
T_SchoolPhoto t
where
not exists(select 1 from T_SchoolPhoto where id>t.id and schoolid=t.schoolid)