You could use/create a UDF for that purpose. FreeUDFLibC has a ROUND UDF (let's call it F_ROUND) that could do the job if you want NULLs to be treated as 0.
Code:
SELECT a+F_ROUND(b) FROM tablename
If you don't want/can't use UDFs, you could always use a small stored proc and use a more complicated query:
Code:
SELECT t.a+(SELECT result FROM nz(t.b, 0)) FROM tablename t
or even:
Code:
SELECT (SELECT result FROM nz(t.a+t.b, t.a)) FROM tablename t
WHERE nz is something like:
Code:
CREATE PROCEDURE NZ (
VAL INTEGER,
DEFVAL INTEGER)
RETURNS (
RESULT INTEGER)
AS
BEGIN
IF (val IS NULL) THEN
result = defVal;
ELSE
result = val;
SUSPEND;
END
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.