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!

Aggregate function -Avg is not working in my sql query

Gayathri VenugopalJun 30 2015 — edited Jun 30 2015

Hi ,

In my query I need to display date and  average age:

SELECT  (SYSDATE-rownum) AS DATE,

avg((SYSDATE - rownum)- create_time) as average_Age

FROM items

group by (SYSDATE-rownum)

output will be something like:

Date_in         Average   Age

24/JUN/15         20

23/JUN/15         19

22/JUN/15         18

But my output for average age is not correct.It's simply calculating/displaying  the output of  (SYSDATE - rownum)- create_time but not calculating the average of them though i use -

avg((SYSDATE - rownum)- create_time) .

Can someone tell me why the aggregate function AVG is not working in my query and what might be the possible solution

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2015
Added on Jun 30 2015
4 comments
1,255 views