Forum

How Range Works in ...
 
Share:
Notifications
Clear all

How Range Works in Analytical Functions?


Posts: 36
Guest
Topic starter
(@Shouman Das)
Eminent Member
Joined: 5 years ago

How Range Works in Analytical Functions?

Specifically -

RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING

 

 

1 Reply
Posts: 46
Guest
(@Sandeep CH)
Eminent Member
Joined: 5 years ago

Range is basically used in the analytical or aggregate functions in SQL. 

When you are using SUM, AUG,  MIN OR MAX in select statement of a particular query as another column by default it takes Unbounded Preceding and Current Row.  

Means if you can take an example of AVG scenario assume that you have 10 rows in a table and you are applying AVG function in for a numarical column.

In this scenario the AVG calculation for each row would be the first row and the current row. 

i.e the AVG calculation for the 5 th Row will be the 1st row and the 5 th row not the 10 th row.

Here by default it takes Rows Range Between Unbounded Preceding and the Current Row.

If you can make it as Rows Range Between Unbounded Preceding and Un Bounded Following then your AVG consideration would be the 1st row and the 10th row since you have 10 rows in your table.

Similarly it also apply for other functions SUM,  COUNT and so on.

I hope you are clear. You can also check this article for more information. 

 

https://www.sqlqueries.in/sql-window-functions/

 

 

 

Reply

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: