SQL server 统计语句
时间: 2024-06-04 13:10:42 浏览: 72
1. SELECT COUNT(*) FROM table_name; -- 统计表中所有行数
2. SELECT COUNT(column_name) FROM table_name; -- 统计表中特定列的非空值数量
3. SELECT SUM(column_name) FROM table_name; -- 计算表中特定列的总和
4. SELECT AVG(column_name) FROM table_name; -- 计算表中特定列的平均值
5. SELECT MAX(column_name) FROM table_name; -- 找出表中特定列的最大值
6. SELECT MIN(column_name) FROM table_name; -- 找出表中特定列的最小值
7. SELECT COUNT(DISTINCT column_name) FROM table_name; -- 统计表中特定列的不同值数量
8. SELECT TOP 10 column_name FROM table_name ORDER BY column_name DESC; -- 找出表中特定列的前十大值
9. SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name; -- 按照特定列进行分组统计
10. SELECT column_name, AVG(column_name2) FROM table_name GROUP BY column_name; -- 按照特定列进行分组计算平均值
阅读全文