posted 6 years ago

I have salary column in my employee table. I have a requirement that while calculating the sum of values in these column, all the negative amounts should be turned to zero.

For example.

SALARY

----------

100

-50

200

-10

Generally when we query as SELECT SUM(SALARY) FROM EMP we get output as 240, but i want to convert -50 and -10 to zero before totalling such that my sum is 100+0+200+0=300

Please let me know if this can be handled through query.

I have salary column in my employee table. I have a requirement that while calculating the sum of values in these column, all the negative amounts should be turned to zero.

For example.

SALARY

----------

100

-50

200

-10

Generally when we query as SELECT SUM(SALARY) FROM EMP we get output as 240, but i want to convert -50 and -10 to zero before totalling such that my sum is 100+0+200+0=300

Please let me know if this can be handled through query.

Agador Paloi

Ranch Hand

Posts: 118