Home > Database > Mysql Tutorial > 例说SQLServer2008聚合函数

例说SQLServer2008聚合函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:21:05
Original
1140 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template