这段程序怎么能实现排序
<table width= "50% " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#999999 ">
<%
dim sy,sm
sy=request( "SY ")
sm=request( "SM ")
%>
<%
dim time1,time2
time1 = sy & "- " & sm & "- " & 1
time2 = sy & "- " & sm+1 & "- " & 1
%>
<tr>
<td height= "30 " align= "center " colspan= "2 "> <%=sy%> 年 <%=sm%> 月 各部门投稿数量 </td>
</tr>
<tr>
<td height= "20 " align= "center "> 部门 </td>
<td height= "20 " align= "center "> 信息量(条) </td>
</tr>
<tr>
<td height= "1 " align= "center " colspan= "2 " bgcolor= "#999999 "> </td>
</tr>
<%
dim bumen,rc
set rs2=server.CreateObject( "ADODB.RecordSet ")
sql= "select * from paiming "
rs2.open sql,conn,1,3
tmpid=rs2.recordcount
bumen=array(0)
rc=array(0)
redim bumen(tmpid)
redim rc(tmpid)
for n=1 to tmpid
bumen(n)=rs2( "bumen ")
response.write ( " <tr onMouseover=this.style.background= '#A3E8ED ' onMouseOut=this.style.background= ' '> <td height=25 align=center> "&bumen(n)& " </td> ")
%>
<%
set rs=server.CreateObject( "ADODB.RecordSet ")
sql= "select * from article_yzinfo where bumen= ' "& bumen(n) & " ' and intime between # "& time1 & "# and # "& time2 & "# "
rs.open sql,conn,1,3
rc(n)=rs.recordcount
response.write ( " <td align=center> <font color=#FF0000> "&rc(n)& " </font> </td> </tr> <tr> <td height=1 align=center colspan=2 bgcolor=#999999> </td> </tr> ")
rs.close
%>
<%
rs2.MoveNext
Next
rs2.Close
%>
</table>
在这段代码中 我先取得一个时间段 然后在paiming这个表中依次取出所有的部门名称 bumen(n), 再在article_yzinfo表中查询在之前的时间段中bumen(n)出现的次数rc(n) 我现在的代码的显示结果是按取出的部门名称bumen(n)的顺序排序,我实际的目的是要按rc(n)的大小排序 并且bumen(n)始终与rc(n)对应
总的来说 目的就是取某个时间段内所有部门出现的次数并按出现的次数多少排序
我觉得可以用冒泡法解决 但是本人因为菜蔬学浅 实在写不出来 请各位高手指点一下 我怕写简单了大家看不明白 所以写的比较详细 先谢谢各位高手先^……
------解决方案--------------------SELECT paiming.bumen, a.c
FROM paiming LEFT JOIN ( SELECT Bumen, count(*) as c FROM