如何用一个sql语句统计分类的总数

songrongtian 2012-06-04 03:00:05
<%rss.open "select top 12 id,newsname,nid from class where nid="&rs("id")&" order by xu",conn,1,1
if rss.eof then
else
while not rss.eof
rsw.open "select count(id) from news where newsid="&rss("id")&"",conn,1,1
dim tt
tt=rsw(0).value
rsw.close
response.write rss("newsname")&tt&
rss.movenext
if not rss.eof then response.write " | "
wend
end if
rss.close%>
我现在的代码是这样的。
样子就像 http://www.peixuncd.com/cdclass.html 这样的
...全文
743 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ynrainy 2012-06-05
  • 打赏
  • 举报
回复
group by 和 sum
熙风 2012-06-04
  • 打赏
  • 举报
回复
select count(id) from news where newsid="&rss("id")& order by 分类ID
Dogfish 2012-06-04
  • 打赏
  • 举报
回复
用group by 吧。
songrongtian 2012-06-04
  • 打赏
  • 举报
回复
二楼能给个代码的例子吗?三楼的写法还得用两条语句!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧