Choosing Rows or Range

  • Comments posted to this topic are about the item Choosing Rows or Range

  • Please, post an example with RANGE!

    I tried this one, so the right answer is PARTITION BY:

    SELECT SUM(object_id)OVER()

    ,SUM(object_id)OVER(PARTITION BY NULL)

    FROM sys.objects

    WHERE object_id < 100

  • select sum(UnitPrice) over (partition by SalesOrderID) price, SalesOrderID from [Sales].[SalesOrderDetail]

    and see below output for above query. output

     

    Can you please share the query with Range?

     

  • The framing is the size of the window. The default is range. This is separate from the partitioning, which you can choose. Without an ORDER BY and without a framing, the default is either the entire range, or unbounded preceding to current row.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply