假如做一个账目统计,一月30天每天都有金额到账,有时候一天有好几笔,现在我要用一个sql语句,根据到账的日期来判断每天的到账金额,具体实现如下:
日          金额
1           100
2           150
3           200
4           600
5           700
6           800
7           900
8           700
      。
该如何用sql统计,向各位大侠求救

解决方案 »

  1.   

    select sum('金额') from table   + 时间过滤条件 不知道你说的意思是这个么
      

  2.   

    select sum(金额) from tb where datediff(d,getdate(),日期)=0
      

  3.   

    说的在详细点吧,有个table表二个字段,date日期 zje总金额2010年8月8日到账100
    2010年8月7日到账100
    2010年8月8日到账200
    2010年8月6日到账100
    我先在要求的显示结果是这样子
    6 100
    7 100
    8 300
    怎么用sql语句写
      

  4.   

    select data,sum(zje) from table group by data
      

  5.   

    select day(date), count(zje) 总金额 from tableName 
    where date>'2010-7-31' and date<'2010-9-1'
    group by day(date)
      

  6.   

    select day(date), count(zje) 总金额 from tableName 
    where date>'2010-7-31' and date<'2010-9-1'
    group by day(date)
      

  7.   

    select sum(金额) from 账目表 group by 日 
      

  8.   


    select a.aa,sum(a.point) from (select CONVERT(varchar(100),createDate, 1) aa,point from Test) a group by a.aa 可以只显示到日,但是会有问题啊,你统计的应该是每个独立的日期,3月5日和4月5日都是5号,难道要加起来吗
      

  9.   

    select day(时间),sum(金额) as 每日总金额 from 账目表 where group by  day(时间)
      

  10.   

    Group By Data时,将Data换成日期,有函数的select data,sum(zje) from table group by CONVERT(varchar(10), data , 120)