sql="select sum(GZ_BZ) as GZ_BZxin,sum(GZ_JB) as GZ_JBxin,sum(GZ_QQ) as GZ_QQxin,sum(GZ_GL) as GZ_GLxin,sum(GZ_YB) as GZ_YBxin,sum(GZ_TX) as GZ_TXxin,sum(GZ_WC) as GZ_WCxin,sum(GZ_WS) as GZ_WSxin,sum(GZ_JT) as GZ_JTxin,sum(GZ_XJ1) as GZ_XJ1xin,sum(GZ_EL) as GZ_ELxin,sum(GZ_ZA) as GZ_ZAxin,sum(GZ_FK) as GZ_FKxin,sum(GZ_XJ2) as GZ_XJ2xin,sum(GZ_SF) as GZ_SFxin from GZ_IN where GZ_BM = '" & Request.QueryString("bm") & "' and GZ_TID = '" & Request.QueryString("ti") & "'"
以上是我的薪资计算代码。。。楼主可以参考一下。。。
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,min(dj),min(mp) from aa group by ph
or
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,mxa(dj),max(mp) from aa group by ph
原帖由 [bold][underline]yms123[/underline][/bold] 于 2007-12-18 20:38 发表 [url=http://bbs.]" border="0" />[/url]
select sum(jj) as jj,sum(sl) as sltotal,ph,dj,mp from aa group by ph
不知道sql能不能用两次聚合函数,楼主可以试试看。
原帖由 [bold][underline]madpbpl[/underline][/bold] 于 2007-12-18 23:15 发表 [url=http://bbs.]" border="0" />[/url]
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,min(dj),min(mp) from aa group by ph
or
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,mxa(dj),max(mp) from aa group by ph
第一句运行后的提示:
Microsoft JET Database Engine '80040e10'
原帖由 [bold][underline]madpbpl[/underline][/bold] 于 2007-12-18 23:15 发表 [url=http://bbs.]" border="0" />[/url]
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,min(dj),min(mp) from aa group by ph
or
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,mxa(dj),max(mp) from aa group by ph
madpbpl 考虑得非常周到, mq 取其max 或 min , dj 取其 max 或 min ,因为 mq 或 dj 会有多条记录 又或者不相同的记录,
而取其一.
但运行时还是有问题, 我把其中的 total 去掉,统计就正确了,但不能获得 mq和dj的数据.
请教madpbpl怎么样才能获得 mq和dj的数据?谢谢!
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,min(dj),min(mp) from aa group by ph
or
select sum(jj) as jjtotal,sum(sl) as sltotal,ph,mxa(dj),max(mp) from aa group by ph