SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select TOP n of each Group
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

olibara
Yak Posting Veteran

87 Posts

Posted - 09/08/2013 :  06:59:11  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1600 Posts

Posted - 09/09/2013 :  17:16:02  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000