注册 登录
编程论坛 ASP技术论坛

[求助]请教诸位:对数据库的总计?

i2008 发布于 2007-08-28 17:09, 386 次点击

对数据库的表mm中的字段gg的值作一个全部的总计和本年的总计及本月的总计.
其中字段tt是日期.当打开网页时自动反映出来这些总计.
请教诸位大哥怎写法?

5 回复
#2
jamesxiaoyao2007-08-28 17:14

select sum(gg).....

#3
天涯听雨2007-08-28 17:55
SumAllCount=Conn.exeCute("select sum(gg) from mm ")(0)

SumYearCount=Conn.exeCute("select sum(gg) from mm where year(tt)='"&year(date())&"'")(0)

SumMonthCount=Conn.exeCute("select sum(gg) from mm where year(tt)='"&year(date())&"' and month(tt)='"&month(date())&"'")(0)
#4
i20082007-08-28 22:20
好像还不行呵.难道我用错?????????????
#5
madpbpl2007-08-28 22:32
楼主如果不介意,最好把你的代码贴出来,让大家帮你分析一下
#6
i20082007-08-29 20:19
以下是引用在2007-8-28 17:55:14的发言:
SumAllCount=Conn.exeCute("select sum(gg) from mm ")(0)

SumYearCount=Conn.exeCute("select sum(gg) from mm where year(tt)='"&year(date())&"'")(0)

SumMonthCount=Conn.exeCute("select sum(gg) from mm where year(tt)='"&year(date())&"' and month(tt)='"&month(date())&"'")(0)

天涯听雨 的代码没错,是本人搞错了,现在已纠正.
鸣谢:天涯听雨

要总计本季度,上一季度和上一月份,要怎样总计呢?

1