当前位置:网站首页>SQL Server 数据库的统计查询
SQL Server 数据库的统计查询
2022-06-29 09:28:00 【小哥丷】
基础数据库表Table为:

查询Table表中某个字段的最大值,最小值,平均数等等。
select MAX(Age) AS 最大年龄,min(Age) AS 最小年龄,avg(Age) AS 平均年龄 from Table
查询结果:

使用 group by 统计查询(男/女)的数量
select Sex AS 性别,COUNT(*) AS 人数 from Table1 group by Sex
查询结果:

使用 group by 统计查询也可以查询多个字段(性别和地址)
select Adderss AS 所在地,Sex AS 性别,COUNT(*) AS 人数 from Table group by Sex,Adderss
查询结果:

使用 having 条件统计查询人数大于2人的地方
select Adderss AS 地址,COUNT(*) AS 人数 from Table group by Adderss having COUNT(*)>=2
查询结果:

边栏推荐
- 2019.10.27 training summary
- 2019.10.20 training summary
- Picture verification code control
- Solve the problem that zxing's QR code contains Chinese garbled code
- BUUCTF--reverse2
- 《CLR via C#》读书笔记-加载与AppDomain
- BUUCTF--reverse1
- 解决zxing的QR码包含中文时乱码的问题
- Comment terminer rapidement une partition de disque
- Summary after the 2009 ICPC Shanghai regional competition
猜你喜欢

Recyclerview sticky (suspended) head

Use of Azkaban in task scheduler

全面理解Synchronized

520 diamond Championship 2021

这个开源项目超哇塞,手写照片在线生成

Real time value transfer from C form to another form

September 29, 2020 non commodity templating code level rapidjson Library

IIS server related error

2021 team programming ladder competition - Simulation Competition

Bug的描述、定级、生命周期
随机推荐
AGCTFb部分题解
Wandering -- the last programming challenge
Installing and configuring wmware esxi 6.5.0 in VMware Workstation
51nod1277 maximum value in string [KMP]
1147 heaps (30 points)
September 17, 2020 gateway business process has two tasks: referer certification and non commodity Templating
Maze walking BFS medium + -- the last programming challenge
Recyclerview universal adapter package
Common usage of LINQ in C #
Ural1517 freedom of choice [suffix array: longest common continuous substring]
2019.11.13 training summary
BUUCTF--内涵的软件
Reading notes of CLR via C -clr boarding and AppDomain
這個開源項目超哇塞,手寫照片在線生成
September 25, 2020 noncopyable of boost library for singleton mode
C#窗体向另一个窗体实时传值
Oracle reset sequence generator (non rebuild)
MySQL中update一条record的过程
Learn spark computing framework in practice (00)
Basic operations during dev use