Skip to toolbar

Forum

How Range Works in ...
 
Notifications
Clear all

How Range Works in Analytical Functions?  


Shouman Das
Posts: 36
 Shouman Das
Guest
(@Shouman Das)
Joined: 2 months ago

How Range Works in Analytical Functions?

Specifically -

RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING

 

 

1 Reply
Sandeep CH
Posts: 42
 Sandeep CH
Guest
(@Sandeep CH)
Joined: 2 months 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 *

Maximum allowed file size is 10MB

 
Preview 0 Revisions Saved
Share: