user E_book
go
select sum(user),play from 表名 where name=6 这样的程序会出错,因为play没有使用sum,所以要分组。
select sum(user),play 表名 where name=6 group by play
有函数的和没有函数的表一起使用要用 GROUP BY
5.AVG 求平均值,只能与数值型一起使用 空值被忽略。
select avg(fitem) from 表名 where name=7
6.MAX和MIN,求最大最小值,空值被忽略 可以和数值、日期、字符一起使用
select MAX(nianling) as 年龄 from 表名
7.count 用于统计记录中的记录数,如果写列名空值被忽略。
select count(*) from user  统计所有记录数
select count (name) from user  统计用户数
例如使用语句count函数来获取employee表中的员工数量。
        use book     --指定数据库
        GO
        select count(employID) from employee
        GO
又如,下面的语句使用sum函数计算sales表中的销售总额
        USE book
        GO
        select sum(linetotal)from sales 
        GO 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-14
  • 2022-12-23
猜你喜欢
  • 2021-08-31
  • 2022-12-23
  • 2021-09-19
  • 2021-09-25
  • 2021-10-26
相关资源
相似解决方案