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!

calculate average in SQL query for days where no record exists

imation3mNov 14 2018 — edited Nov 14 2018

Hi,

I need to calculate the average daily closing balance of an account for a week (7 Oct 2018 till 13 Oct 2018), but the account opened in the middle of the week (9 Oct 2018), so records exists in the table from date opening date, if i apply AVG function, it will calculate average for 5 days but not for 7 days. How to feed the missing days with closing balance of zero, so the average function can calculate correctly for 7 days.

Needs to be done in select query only.

Sample data below:

Datesclosing balance
09-Oct-1825000
10-Oct-1825000
11-Oct-1825000
12-Oct-1825000
13-Oct-1825000
This post has been answered by BEDE on Nov 14 2018
Jump to Answer
Comments
Post Details
Added on Nov 14 2018
11 comments
1,449 views