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!

NULL values in SUM

497390Jun 1 2007 — edited Jun 1 2007
Hi,
I'm trying find optimal solution for problem:

I have query:
SELECT
  col_2,
  SUM(col_1)
FROM table_1
GROUP BY
col_2;
in col_1 are possible NULL values, how to make SUM return NULL if any of values col_1 in SUM for specific col_2 is NULL.
I have some solution but its very heavy :
...
CASE
  WHEN SUM(col_1) = SUM(NVL(col_1,-1000))
  THEN SUM(col_1)
  ELSE NULL
END
...
Does anyone see some better solution?

P.S. analytical function are not very welcome :)
Thanks for help

--
Krzysiek Wojszko
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2007
Added on Jun 1 2007
7 comments
421 views