0

现在,我正在尝试通过循环从表中获取前 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 获取顶级数据我如何将它循环到它将获得第一个、第二个第三个、....第十个数据的位置?

4

2 回答 2

0
 Group by ClientUserName, DestHost order by counts desc LIMIT 10
于 2012-06-27T19:43:50.617 回答
0

您不能循环,但您可以执行以下操作并更改要在子查询中选择的记录数:

   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-27T19:47:26.260 回答