当前位置:首页 > PHP教程 > PHP总结归纳

例说SQLServer2008聚合函数

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 create table tb_class( classid int not null identity, classname nvarchar(16) not null, students int not null, teacher nvarchar(16) not null, primary key(classid)) insert into tb_class(classname,students,

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

create table tb_class(

classid int not null identity,

classname nvarchar(16) not null,

students int not null,

teacher nvarchar(16) not null,

primary key(classid))

insert into tb_class(classname,students,teacher)

values

('1班',25,'yl'),('2班',18,'wsp'),('3班',24,'yl'),('4班',25,'zhy'),

('5班',22,'wsp'),('6班',25,'yl'),('7班',20,'zhy'), ('8班',22,'wsp')

select sum(students) from tb_class group by teacher

select count(students) from tb_class group by teacher

select avg(students) from tb_class group by teacher

select max(students) from tb_class group by teacher

select min(students) from tb_class group by teacher

.syntaxhighlighter{padding-top:20px;padding-bottom:20px;}
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!