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

15,662

You should decode the values with 0 not with NULL;

select MAX(DECODE(some_number,1,max_val,0)) val1,
       MAX(DECODE(some_numer,2,max_val,0)) val2,
       MAX(DECODE(some_numer,3,max_val,0)) val3 
  from EX_TABLE
Share:
15,662
Vijay Vasanth
Author by

Vijay Vasanth

C++ Developer

Updated on June 12, 2022

Comments

  • Vijay Vasanth
    Vijay Vasanth almost 2 years

    I'm getting this warning:

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

    when using Oracle's MAX() function in production. I'm using the OCI library to connect to Oracle, version 11.2.0.2.

    But, on the testing server, this error is not coming. I've hard-coded the query in such way that a NULL value can be passed to an aggregate function. I still couldn't reproduce this issue.

    Is this warning related to any Oracle bug? Can anyone provide some example query which will throw this warning?

    Edit:

    Table: EX_TABLE
    Columns:
    ID NOT NULL NUMBER
    SOME_NUMBER NUMBER
    MAX_VAL NUMBER
    

    Query:

    select MAX(DECODE(some_number,1,max_val,NULL)) val1
         , MAX(DECODE(some_number,2,max_val,NULL)) val2
         , MAX(DECODE(some_number,3,max_val,NULL)) val3 
      from EX_TABLE