Try Mailstrom: the faster, smarter, free way to Inbox Zero.

Replyz collects and amplifies questions from around the web, allowing a wider audience to answer them.

Share your knowledge and build your reputation by posting helpful replies.

#sqlhelp I have gotten as far as SUM(Sales) OVER(PARTITION BY Division). That pulls back all custs for all divisions. How do I get top 10?

3:09PM Wed, April 21 2010

Mvp_photo_normal @Adam_Haines

filter the cte by the row num column aliased in the cte earlier e.g. where rownum <=10 #sqlhelp

3:11PM Wed, April 21 2010

Img_9925_twitter2_normal @grrl_geek

Do you have an example?

3:14PM Wed, April 21 2010

Hermes_normal @DenisGobo

kind of difficult to do with twitter...give me a sec

3:16PM Wed, April 21 2010

Doubles_6_normal @rhurwitz

use a RANK() over (PARTITION BY division) as [rank] in your select clause

3:17PM Wed, April 21 2010

Mvp_photo_normal @Adam_Haines

WITH cte AS(SELECT *,ROW_NUMBER() OVER(PARTITION BY div ORDER BY amt DESC) AS seq FROM )SELECT * FROM cte WHERE seq <=10

3:22PM Wed, April 21 2010

anonymous Anonymous

Write a Reply

Posting to Twitter as @ReplyzAnon (why?)

500 CHARS

You are not signed in. Create an account to get all the benefits of Replyz including no reCAPTCHA challenges. It's easy!

Like to reply? Try Flashcards

Flashcards is a quick and fun way to share your knowledge about topics you like to tweet about. Sign in with Twitter and we’ll show you questions you can’t resist!
Sign in with Twitter