想查出同名次数2次及以上的数据,总报“错误 '80020009' ”

germ007 2013-08-16 10:58:59
想查出同名次数2次及以上的数据,总报“错误 '80020009' ”


table1
id name time
1 tom 2011
2 john 2009
3 tom 2012
4 joly 2013
5 john 2013
想查出同名次数2及以上的数据


<%

set rs=server.CreateObject("adodb.recordset")
rs.open "select Name,count(id) as tota1 from table1 group by Name order by tota1 desc",conn,1,1
do while not rs("total")<2
response.Write(rs("name")&rs("tota1")&"<br>")
rs.movenext
loop
rs.close
set rs=nothing


%>



结果显示

tom2
john2

错误 '80020009'
...全文
206 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
germ007 2013-08-16
  • 打赏
  • 举报
回复
谢谢,试过了,还是显示“错误 '80020009' ”
fzfei2 2013-08-16
  • 打赏
  • 举报
回复
do while not rs.eof and   rs("total")>=2
街头小贩 2013-08-16
  • 打赏
  • 举报
回复
好好看看的SQL语句

rs.open "select Name,count(id) as tota1 from table1  group by Name order by tota1  desc",conn,1,1
是tota1不是total,最后一个字符你在SQL中是1
zhanghongwen 2013-08-16
  • 打赏
  • 举报
回复
set rs=server.CreateObject("adodb.recordset") rs.open "select * from (select Name,count(id) as tota1 from table1 group by Name)T where tota1<2 order by tota1 desc",conn,1,1 do while not rs.Eof response.Write(rs("name")&rs("tota1")&"<br>") rs.movenext loop rs.close set rs=nothing 试一下这样

28,409

社区成员

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

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