Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • This works perfectly, I missed on adding the last level of nesting query there. Also the only change we need to make here is to add Revenue in the Group By of BS inner SQL otherwise we won't be able to use it in the partition of Row_Number(). That's the only extra thing I added and it's working perfectly now..tx Commented Oct 11, 2013 at 1:58