Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display 0 in the place of a negative number

Status
Not open for further replies.

renee35

MIS
Jan 30, 2007
199
Could someone help me incorporate into this formula not to pick up any values that are negative (if c.column1 is a negative number I want it to show 0):


SELECT isnull(sum(isnull(c.column1,0)),0)
from table a (READCOMMITTED)
LEFT OUTER JOIN table b (READCOMMITTED)
ON b.column = a.column
LEFT OUTER JOIN tablex c (READCOMMITTED)
ON c.column = a.column

Thanks a bunch!!

-T
 
Are you sure you are in the correct forum? Your last two threads deal with T-SQL questions, but you are posting in the Reporting Services forum. There is a SQL Server Programming forum here for T-SQL questions.

Anyways, here is your answer:

Code:
   SELECT 
	SUM(
		CASE
			WHEN c.Column1 < 0 THEN 0
			ELSE c.Column1
		END) 
    from table1 a  (READCOMMITTED)
      LEFT OUTER JOIN table2 b (READCOMMITTED)
      ON b.column2 = a.column2
      LEFT OUTER JOIN tablex c (READCOMMITTED)
      ON c.column2 = a.column2
 
Thanks and have a great weekend!!

Thanks a bunch!!

-T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top