asp统计排序
一个棘手的问题实在是想不出来了希望各位帮忙一下谢谢了有两个表(sqlserver)(栏目)表1:IDparentidclassid(新闻表)表2:idparentidna...
一个棘手的问题 实在是想不出来了 希望各位帮忙一下 谢谢了
有两个表 (sql server)
(栏目)表1:ID parentid classid
(新闻表)表2:id parentid name
现在要统计栏目表中每个栏目(parentid)在新闻表中有多少条记录,然后 再按照统计结果降序排序
目的是要做一个排行榜
栏目名 稿件数
<%
Set Rs=Server.CreateObject("ADODB.Recordset")
SQL = "select * from ClassList order by id desc"
'Set Rs = Conn.execute(SQL)
Rs.Open SQL,Conn,3,2
If Not Rs.eof Then
Do while not rs.eof
totle = ""
Set Rs1=Server.CreateObject("ADODB.Recordset")
SQL1 = "select parentid from News where parentid="& Rs("id") &" order by id desc"
'SQL1 = "select parentid,count(parentid) from news where parentid="& Rs("id") &" group by parentid order by count(parentid) "
'Set Rs1 = Conn.execute(SQL1)
Rs1.Open SQL1,Conn,3,2
If Not Rs1.eof Then
totle = Rs1.recordcount
End if
Rs1.Close
set rs1= nothing
%> 展开
有两个表 (sql server)
(栏目)表1:ID parentid classid
(新闻表)表2:id parentid name
现在要统计栏目表中每个栏目(parentid)在新闻表中有多少条记录,然后 再按照统计结果降序排序
目的是要做一个排行榜
栏目名 稿件数
<%
Set Rs=Server.CreateObject("ADODB.Recordset")
SQL = "select * from ClassList order by id desc"
'Set Rs = Conn.execute(SQL)
Rs.Open SQL,Conn,3,2
If Not Rs.eof Then
Do while not rs.eof
totle = ""
Set Rs1=Server.CreateObject("ADODB.Recordset")
SQL1 = "select parentid from News where parentid="& Rs("id") &" order by id desc"
'SQL1 = "select parentid,count(parentid) from news where parentid="& Rs("id") &" group by parentid order by count(parentid) "
'Set Rs1 = Conn.execute(SQL1)
Rs1.Open SQL1,Conn,3,2
If Not Rs1.eof Then
totle = Rs1.recordcount
End if
Rs1.Close
set rs1= nothing
%> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询