problem getting sum of each row
-
Hi, I'm trying to get total of each row in my table. For eample, I have columns x, y and z (all int). To get total, i'm writing "select (x + y + z) As total from myTable". It works fine as long as one of the colunm is not empty. If it finds any null data in x, y or z then total shows up null. How can i get total in such case? Thanks in advance
-
Hi, I'm trying to get total of each row in my table. For eample, I have columns x, y and z (all int). To get total, i'm writing "select (x + y + z) As total from myTable". It works fine as long as one of the colunm is not empty. If it finds any null data in x, y or z then total shows up null. How can i get total in such case? Thanks in advance
-
Hi, I'm trying to get total of each row in my table. For eample, I have columns x, y and z (all int). To get total, i'm writing "select (x + y + z) As total from myTable". It works fine as long as one of the colunm is not empty. If it finds any null data in x, y or z then total shows up null. How can i get total in such case? Thanks in advance
Any expression containing a null value will evaluate to null. There are a couple of ways around this. You could define your database columns so that they are not allowed to contain null values, and assign them a default value of zero. Another method would be to test each value for null, and use 0 for the value of that operand if the result is true. Hope that helps.
-
Thank you very much! IsNull worked fine.
-
Hi, I'm trying to get total of each row in my table. For eample, I have columns x, y and z (all int). To get total, i'm writing "select (x + y + z) As total from myTable". It works fine as long as one of the colunm is not empty. If it finds any null data in x, y or z then total shows up null. How can i get total in such case? Thanks in advance