Home » SQL & PL/SQL » SQL & PL/SQL » avg() function
avg() function [message #209522] Fri, 15 December 2006 06:08 Go to next message
nirmalsampang
Messages: 1
Registered: December 2006
Location: kathmandu
Junior Member

Hello everyone,

i was asked in my exam, what does avg() function do when there is null in the column, options were like
a) doesnt count the row
b) generates error
c) turns null to zero
d) i forgot the option

plz help.
Re: avg() function [message #209524 is a reply to message #209522] Fri, 15 December 2006 06:11 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why wouldn't you create a test case and try it by yourself? It is really a simple one.
Re: avg() function [message #209874 is a reply to message #209522] Mon, 18 December 2006 04:17 Go to previous messageGo to next message
venurajkumar
Messages: 4
Registered: December 2006
Location: chennai
Junior Member
avg() function will ignore the null value from the column
Re: avg() function [message #209878 is a reply to message #209874] Mon, 18 December 2006 04:30 Go to previous message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
It does. And it is the intended behaviour.
All aggregate functions like sum,count,avg,etc do the same.
If you want that to be considered use nvl with some value (0 or whatever depending on your requirement)

By
Vamsi

[Updated on: Mon, 18 December 2006 04:31]

Report message to a moderator

Previous Topic: How to create/use composite keys.
Next Topic: Help needed in query tuning
Goto Forum:
  


Current Time: Sat Dec 03 10:13:32 CST 2016

Total time taken to generate the page: 0.12270 seconds