这个查询语句问什么不执行!求教!

wenqiangyang 2003-10-16 03:20:39
table1:ip(id,onip,offip,addr)ip地址分布表
table2:visittimes(vtime,ipnum)
要求:统计visittimes表中访问ip地址在各个地区的分布。

select count(*),id from ip where EXISTS
(select ipnum from visittimes where ipnum between ip.onip and ip.offip) group by id

我这个语句有什么问题,好像是死循环似的,得不到结果,急。

顺便问一下,怎么能够给别人加分。
...全文
23 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nadylu 2003-10-16
  • 打赏
  • 举报
回复
结贴,点击管理。
nadylu 2003-10-16
  • 打赏
  • 举报
回复
select count(distinct A.id)
from ip A,visittime B
where B.ipnum between A.onip and A.offip
group by A.id
sdhdy 2003-10-16
  • 打赏
  • 举报
回复
select B.id,count(b.id) from visittimes A ,ip B
where A.ipnum between B.onip and B.offip group by B.id

点管理按钮给分
pengdali 2003-10-16
  • 打赏
  • 举报
回复
select count(*),a.id from ip a left join visittimes b on b.ipnum between a.onip and a.offip group by a.id
yujohny 2003-10-16
  • 打赏
  • 举报
回复
select B.id,count(*)
from visittimes A inner join ip B
ON A.ipnum between B.onip and B.offip
group by B.id

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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