Access SUM()
-
Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron
-
Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron
http://office.microsoft.com/en-us/access/HA012315151033.aspx[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Hi, I'm using an Access database in my C# win application. I need to sum values from two different tables and then subtract one of the SUM values from the other. No problem until I runn into one of the SUM values = null. I need it to return 0 if null is the result of the SUM. What is the best way to handle this... with an IIF? IIF(SUM(OrderTotal) IS NULL,0,SUM(OrderTotal)) ??? Thanks for any help you can give. Ron
nz(sum(OrderTotal),0)
-
nz(sum(OrderTotal),0)
Thanks andyharman, I tried but it came up with an error so I researched it. Looks like NZ can't be used with SQL OLE DB, just within MS Access program. ron
-
Thanks andyharman, I tried but it came up with an error so I researched it. Looks like NZ can't be used with SQL OLE DB, just within MS Access program. ron
If you are using SQL Server then the syntax is:
isnull(sum(YourColumn), 0)