I have two columns Val1 and Val2 as int in SQL Server 2008 When I select Tot = Val1+Val2 from Table, I get null as Tot
How do I get total of two int columns selected?
Many thanks.
It's likely that you have a null value in one of the columns. that will produce a null-valued result.
You can do the following, if you want null to represent 0.
SELECT Tot = ISNULL(Val1, 0) + ISNULL(Val2, 0)
FROM Table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With