表A
bdepart char(12)
salary1 float
salary2 float
salary3 float
salary4 float
salary5 float
salary6 float
salary7 float
salary8 float
salary9 float
erji char(1)
bdepartpid char(4)现在想把数据根据条件汇总到一张汇总表B里作统计然后绑定到GridView
表B
bdepart char(12)
tongji1 float 条件1
tongji2 float 条件2
....其中数据汇方法如下:
先select distinct bdepart from A where erji='t' order by bdepartpid
for i=0 to bdepart的记录数
select sum(salary1) from A where bdepart=@bdepart
插sum(salary1)到表B的tongji[i]中
next请问这样的后台语法如何写呀?(顺便问一下,是像我这样写好还是先放到dataset再插到数据库?)
bdepart char(12)
salary1 float
salary2 float
salary3 float
salary4 float
salary5 float
salary6 float
salary7 float
salary8 float
salary9 float
erji char(1)
bdepartpid char(4)现在想把数据根据条件汇总到一张汇总表B里作统计然后绑定到GridView
表B
bdepart char(12)
tongji1 float 条件1
tongji2 float 条件2
....其中数据汇方法如下:
先select distinct bdepart from A where erji='t' order by bdepartpid
for i=0 to bdepart的记录数
select sum(salary1) from A where bdepart=@bdepart
插sum(salary1)到表B的tongji[i]中
next请问这样的后台语法如何写呀?(顺便问一下,是像我这样写好还是先放到dataset再插到数据库?)
set rs=server.createobject("Adodb.Recordset")
sql="select distinct bdepart from A where erji='t' order by bdepartpid"
rs.open sql,conn,1,1
while not rs.eof set rs2=server.createobject("Adodb.RecordSet")
sql2="select sum(salary1) as salary1 from A where bdepart='"&rs(bdepart)&"'"
rs2.open sql2,conn,1,1
sql3="insert into b set tongji1=rs2("salary1") where bdepart='"&rs(bdepart)&"'"
conn.execute(sql3)
rs2.close
set rs2=nothingrs.movenext
next
rs.close
set rs=nothing
from t_test
union all
select to_char(max(decode(id,1,id))) f1,to_char(max(decode(id,2,id)))f2,to_char(max(decode(id,3,id)))f3,to_char(max(decode(id,4,id)))f4
from t_test
我也没试过,是在别的地方找的,你可以试试