
1个回答
展开全部
楼主我给您一些思路吧,不知道能否满足你的需求,纯手打,只是思路:
1、首先通过表2的统计查询得出每个国家(地区)的项目数量(即表2中的ch字段的数量,因为ch字段数量每个国家不同的,所以要先把ch字段的数量统计出来,以便在后面的表格中展示):
select gj,count(gj) as chs from 表2 where gj in (select gj from 表1) group by gj
这样就得到每个国家对应的ch的数量chs,假设记录集为RS,则通过do while 循环,再次对表2进行查询,即可得出你的结果:
do while not RS.eof
response.write "<table>"
response.write "<tr><td colspan='"&(RS("chs")+1)&"'>"&rs("gj")</td></tr>" '注意colspan即gj的项目数量chs+1,有了这个才能画出你要的表格的效果,否则表格列会错开来
2、再次对表2进行查询
sql="select ch,zhi from 表2 where gj='"&RS("gj")&"'" ‘下面假设该sql语句对应记录集为rs0,则运用do while循环得到项目的那行:
response.write "<tr><td>项目</td>" '开始项目行
do while not rs0.eof
response.write "<td>"&rs0("ch")&"</td>"
rs0.movenext
loop
response.write "</tr>" '结束项目行
rs0.movefirst '把rs0记录集指针跳到第一个,再次用do while 循环开始第二行
response.write "<tr><td>数值</td>" '开始数值行
do while not rs0.eof
response.write "<td>"&rs0("zhi")&"</td>"
rs0.movenext
loop
response.write "</tr>" '结束数值行
rs0.close
set rs0=nothing ’关闭和清空rs0记录集
response.write "</table>" '结束一个表
response.write "<br>" '空一行
RS.movenext
loop ‘外循环继续
’最后记得关闭RS记录集
1、首先通过表2的统计查询得出每个国家(地区)的项目数量(即表2中的ch字段的数量,因为ch字段数量每个国家不同的,所以要先把ch字段的数量统计出来,以便在后面的表格中展示):
select gj,count(gj) as chs from 表2 where gj in (select gj from 表1) group by gj
这样就得到每个国家对应的ch的数量chs,假设记录集为RS,则通过do while 循环,再次对表2进行查询,即可得出你的结果:
do while not RS.eof
response.write "<table>"
response.write "<tr><td colspan='"&(RS("chs")+1)&"'>"&rs("gj")</td></tr>" '注意colspan即gj的项目数量chs+1,有了这个才能画出你要的表格的效果,否则表格列会错开来
2、再次对表2进行查询
sql="select ch,zhi from 表2 where gj='"&RS("gj")&"'" ‘下面假设该sql语句对应记录集为rs0,则运用do while循环得到项目的那行:
response.write "<tr><td>项目</td>" '开始项目行
do while not rs0.eof
response.write "<td>"&rs0("ch")&"</td>"
rs0.movenext
loop
response.write "</tr>" '结束项目行
rs0.movefirst '把rs0记录集指针跳到第一个,再次用do while 循环开始第二行
response.write "<tr><td>数值</td>" '开始数值行
do while not rs0.eof
response.write "<td>"&rs0("zhi")&"</td>"
rs0.movenext
loop
response.write "</tr>" '结束数值行
rs0.close
set rs0=nothing ’关闭和清空rs0记录集
response.write "</table>" '结束一个表
response.write "<br>" '空一行
RS.movenext
loop ‘外循环继续
’最后记得关闭RS记录集
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询