select sum(字段) from table

解决方案 »

  1.   

    select sum(字段) from table
      

  2.   

    如果你没有分类别统计  那么就是
    select sum(字段) from table如果你分类别统计
    比如你有一个字段 是
    color
    红色 黑色 蓝色
    那么就你的SQL
    select sum(字段) as sumNumber from table group by color order by sumNumberOk.
      

  3.   

    select sum(colunmname) as Totalcolunmname 
    from tableName
    group by convert(char(10),columnDatetime,120)
      

  4.   

    那,假如我要统计在一个班里不同科目的学生的总数,又应该怎样呢???????
    例如化学的人数是多少,物理的人数是多少?
    但SUM()函数只是求数值型的函数
    我应用哪个函数才能把各科目学生的人数统计出来??
      

  5.   

    select count(chemistry)
    from table
    group by chemistry -- 你想根据什么统计,这里就是什么
    --order by id 视情况而定,可要可不要
      

  6.   

    select sum(需相加的字段) as 总值,其它统计的字段1,其它统计的字段2...
    from 表
    where 日期 between '2005-05-01 00:00:00' and '2005-05-01 23:59:59' --5月1日这天
    group by 其它统计的字段1,其它统计的字段2...
      

  7.   

    txqgyf(执着与爱) :
    你的这个问题应该使用
    count 方法
    它的用法和Sum一样
    而且也可以进行排序。
    用我刚才的例子
    比如我要统计 不同颜色的产品分别有多少select count(color) as conNumber from table group by color order by conNumber