Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple NVL question

587 views
Skip to first unread message

Glen A. Stromquist

unread,
Jan 5, 2001, 4:08:17 PM1/5/01
to
It must be friday, my brain has locked up already...

I want to do a query on a table that sums a column that may have null
values. So I type in:

select field1, nvl(sum(field2),0)
from table
group by field1

ERROR:
ORA-24347: Warning of a NULL column in an aggregate function

Interestingly enough, the same query without the NVL function returns
results when I run it in a TOAD window.

I'm missing something obvious here... what is it?


Sent via Deja.com
http://www.deja.com/

hanna...@my-deja.com

unread,
Jan 5, 2001, 4:24:46 PM1/5/01
to
select field1, sum(nvl(field2,0)) from ...

In article <935d3r$7iq$1...@nnrp1.deja.com>,

Business

unread,
Jan 5, 2001, 4:31:39 PM1/5/01
to
sum(nvl(field2,0))

The NVL shouldn't be necessary. A column with nulls adds nothing to the
results.

"Glen A. Stromquist" <gle...@my-deja.com> wrote in message
news:935d3r$7iq$1...@nnrp1.deja.com...

John Russell

unread,
Jan 20, 2001, 5:23:53 PM1/20/01
to


Don't you mean:

select field1, sum(nvl(field2,0))

so that SUM is always operating on either the value from the column,
or 0 if the value is null?

For interest's sake, here's a way to find the code examples for NVL
(or any other statement, function, etc.) from the Oracle docs:

http://tahiti.oracle.com/pls/tahiti/tahiti.drilldown?word=nvl&book=&preference=Examples&expand_all=1

John

0 new messages