View previous topic :: View next topic
|
Author |
Message |
praveenhu
New User
Joined: 23 Jun 2006 Posts: 5
|
|
|
|
Hi,
The query looks some thing like this:
Select sum(abc)
into :xyz:xyz-n
from tablename;
If the sum() function returns Value zero, then wat will be the NULL Indicator value.
Please help me in this, this is of high priority to me |
|
Back to top |
|
|
achusarath
New User
Joined: 21 Mar 2007 Posts: 26 Location: kerala
|
|
|
|
value will be zero since the result is zero which is a value in column . |
|
Back to top |
|
|
praveenhu
New User
Joined: 23 Jun 2006 Posts: 5
|
|
|
|
But in my case, its returning <0 value; After sql i am checking whether the NULL indicator < 0 and the sum() value = 0, its satisfying the condition... Even i am confused how is this possible...
Looking for the reply...
Thanks for the quick response |
|
Back to top |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
Back to top |
|
|
vini_srcna
Active User
Joined: 26 May 2005 Posts: 178 Location: Copenhagen, Denmark
|
|
|
|
you can see the difference with the sample query against the QMF sample tables.
SELECT SUM(DEPT) FROM Q.STAFF WHERE DEPT = 10
&
SELECT SUM(DEPT) FROM Q.STAFF WHERE DEPT = 99
I put it like this way. When there is an aggregate function is used in a query and if there are no rows satisfying the WHERE predicate, then DB2 will give NULL value. Its same with MAX,MIN,AVG,SUM and etc...but not with COUNT..!!
Confused..? Then you should refer to manual. I may not be clear in explaining. |
|
Back to top |
|
|
|