现在,我试图通过循环从表中获取前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的顶级数据如何将其循环到它将获得第一,第二,第三......第十个数据的位置?
答案 0 :(得分:0)
Group by ClientUserName, DestHost order by counts desc LIMIT 10
答案 1 :(得分: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