select c.name, (select group_concat(name) from student s where s.class_id =c.id ) from class c
select
id,name,phone,
sum(case when type='in' then 1 else 0 end) cnt_in,
sum(case when type='out' then 1 else 0 end) cnt_out,
sum(case when iflocal='1' then 1 else 0 end) cnt_local,
sum(case when iflocal='0' then 1 else 0 end) cnt_nonlocal,
sum(case when type='in' then input_time else 0 end) alltime_in,
sum(case when type='out' then input_time else 0 end) alltime_out
from userlist a join phonelist b
on a.phone=b.phone group by a.phone;
来自:
http://blog.csdn.net/textalign/article/details/71746973