Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Range between unbounded preceding: default for windowing clause: question

2776946Jan 18 2016 — edited Jan 18 2016

from online article near the bottom: https://oracle-base.com/articles/misc/analytic-functions

question is about the part I bolded below.

image.png

There are two things to notice here.

  • The addition of the order_by_clause without a windowing_clause means the query is now returning a running average.
  • The default windowing_clause is "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW", not "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW". The fact it is RANGE, not ROWS, means it stops at the first occurrence of the value in the current row, even if that is several rows earlier. As a result, duplicate rows are only included in the average when the salary value changes. You can see this in the last two records of department 20 and in the second and third records of department 30.

it mentions duplicates included if the salary changes. I don't notice a salary change in the duplicates the output display, not in the salary nor the individual salary averages (last two records of department 20 for example both the salaries show 3000 respectively). Could someone please clarify what this part of the article is trying to say.

Looked at it again and think I understand...

The duplicate displays are only included once into the running average not twice. Is THAT what it is trying to tell me??

I think this is correct but would rather not make a bad assumption.

This post has been answered by Solomon Yakobson on Jan 18 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2016
Added on Jan 18 2016
3 comments
484 views