Search code examples
sqloracle-databaseoraclereports

Sum all row exclude the negative numbers in Oracle Reports


I have one table with 10 rows. I want to sum the values in a particular column. But I want to exclude all the negative numbers.

How can I sum just the positive numbers and ignore the negative numbers?

This is my pictures example: sample


Solution

  • You can do something like

    SELECT SUM( case when column_name > 0 
                     then column_name
                     else 0
                  end ) sum_of_non_negative
      FROM table_name