asp中一个查询语句问题 在线急等!!

2025-05-13 02:47:59
推荐回答(1个)
回答1:

connection 你就自己写吧

sql="select department from other group by department"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,1,3

depts=""
do while not rs.eof
depts=depts&","&rs("department")
rs.movenext
loop

for each dept in split(depts,",")
sql1="select type,count(type) as NUM from other where department='"&dept&"' group by type "
set rs1=Server.CreateObject("ADODB.Recordset")
rs1.Open sql1,conn,1,3
response.Write(dept&":  ")

do while not rs1.eof
response.Write(rs1("type")rs1("NUM")&"台    ")
rs1.movenext
loop
rs1.close
response.Write("
")
next