日期:2014-05-18 浏览次数:20677 次
select b.员工所属部门 部门 , min(a.培训时间) 该部门员工参加培训的最少天数 from a,b where a.员工号=b.员工号
------解决方案--------------------
create table A(id int,days int) create table B(id int,department varchar(50)) insert into A select 1 , 2 union all select 2 , 4 union all select 3 , 6 union all select 4 , 3 union all select 5 , 1 union all select 6 , 1 insert into B select 1 , '办公室' union all select 2 , '办公室' union all select 3 , '客服' union all select 4 , '客服' union all select 5 , '开发' union all select 6 , '开发' select B.department as '部门', count(A.id) as '部门员工数', min(A.days) as '该部门员工参加培训的最少天数' from A,B where A.id=B.id group by B.department