zoukankan      html  css  js  c++  java
  • group by 语句

    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 
  • 相关阅读:
    17_8_30 Mybatis 入门
    17_8_29 mysql 导入导出备份还原
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [MAC OSX
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
  • 原文地址:https://www.cnblogs.com/xiaowie/p/8675086.html
Copyright © 2011-2022 走看看