create table tb(depart char(3),name varchar(100),numb int)
insert into tb select '001','dai',20
union all select '002','dai',20
union all select '003','dai',20
union all select '004','wang',20
union all select '005','wang',20
union all select '006','deng',20
select * from tb
select distinct name ,sum(numb) as sum_numb from tb group by name
drop table tb
insert into tb select '001','dai',20
union all select '002','dai',20
union all select '003','dai',20
union all select '004','wang',20
union all select '005','wang',20
union all select '006','deng',20
select * from tb
select distinct name ,sum(numb) as sum_numb from tb group by name
drop table tb
insert into tb select '001','dai',20
union all select '001','dai',20
union all select '003','dai',20
union all select '005','wang',20
union all select '005','wang',20
union all select '006','deng',20
select * from tb
select distinct name ,depart,sum(numb) as sum_numb from tb group by name,depart
drop table tb
select depart=min(depart),name,sum(numb) from test group by name
但是我的数据库是access,我把这个sql放asp里面就不行了!
奇怪?
这个在asp里面可以
select depart=min(depart),name,sum(numb) from test group by name
但是这个就不行了!