create table tb(id int,x int,y int,z int) insert into tb select 1,3,5,6 insert into tb select 1,4,4,6 insert into tb select 1,7,5,3 insert into tb select 2,3,5,6 insert into tb select 2,8,3,3 insert into tb select 2,9,4,2 insert into tb select 2,3,5,1 go select id,avg(x)avgx,avg(y)avgy from tb group by id go drop table tb /* id avgx avgy ----------- ----------- ----------- 1 4 4 2 5 4(2 行受影响)*/
select id,avg(x),avg(y) from tb group by id
select id,avg(x),avg(y) from tb group by id
select id,avg(x),avg(y) from tb group by id
select id,avg(x),avg(y) from tb group by id
select id,avg(x),avg(y) from tablename group by id
insert into tb select 1,3,5,6
insert into tb select 1,4,4,6
insert into tb select 1,7,5,3
insert into tb select 2,3,5,6
insert into tb select 2,8,3,3
insert into tb select 2,9,4,2
insert into tb select 2,3,5,1
go
select id,avg(x)avgx,avg(y)avgy from tb group by id
go
drop table tb
/*
id avgx avgy
----------- ----------- -----------
1 4 4
2 5 4(2 行受影响)*/