现在,我正在尝试通过循环从表中获取前10个数据。
Select ClientUserName, DestHost, count(DestHost) counts from #ProxyLog_record
where ClientUserName =(Select top 1 ClientUserName from #ProxyLog_count_2)
Group by ClientUserName, DestHost order by counts desc 这只会从clientusername获取顶部数据如何才能将其循环到将获取第一个、第二个、第三个数据的位置...第十个数据?
发布于 2012-06-28 03:47:26
您不能循环,但您可以这样做,并更改子查询中要选择的记录的数量:
Select ClientUserName, DestHost, count(DestHost) counts from #ProxyLog_record
where ClientUserName in (Select top 10 ClientUserName from #ProxyLog_count_2)
Group by ClientUserName, DestHost order by counts desc 发布于 2012-06-28 03:43:51
Group by ClientUserName, DestHost order by counts desc LIMIT 10https://stackoverflow.com/questions/11233753
复制相似问题