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.

3
  • With COUNT(*) OVER (PARTITION BY Receipt_number, Quanity) , you could have only 1 CTE. Commented Feb 28, 2019 at 12:04
  • 1
    I have 0 now, but I see your point ;-) I'm not entirely sure what the OP wants, so I more or less just copied the original query and adapted it. Commented Feb 28, 2019 at 12:24
  • I meant 1 level of CTEs or derived table, instead of 2 levels. Commented Feb 28, 2019 at 12:33