Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select TOP n of each Group

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2013-09-08 : 06:59:11
Hello I'm trying to find the most effective way to get the top N of each group in a group by

I've already try the ROW_NUMBER() OVER PARTITION Method but it is still slow

I've also checked the CROSS APPLY Method not really more efficient

Bu t My group is very simple and limited to one column
So Now I'm on the way to use a stored procedure make a loop of TOP n for each distinct element of my column

Any comment or other Idea ?

Thanks for any help

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-09-09 : 17:16:02
The ROW_NUMBER() OVER PARTITION approach seems to be the way to go. Let us see your code and perhaps someone can determine why it is running slow. Also, can you quantify what "slow" actually means?

=================================================
The cure for anything is salt water -- sweat, tears, or the sea. -Isak Dinesen
Go to Top of Page
   

- Advertisement -