Now, I am trying to get the top 10 data from the table through a loop.
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
What this does only gets the top data from clientusername how can i loop it to where it will get the first, second third,…. tenth data?
You can’t loop but you could do something like this and change the number of records to select in the sub query: