SELECT max(x) is returning null; how can I make it return 0?
or:
SELECT coalesce(MAX(X), 0) AS MaxX
FROM tbl
WHERE XID = 1
In SQL 2005 / 2008:
SELECT ISNULL(MAX(X), 0) AS MaxX
FROM tbl WHERE XID = 1
or:
SELECT coalesce(MAX(X), 0) AS MaxX
FROM tbl
WHERE XID = 1
In SQL 2005 / 2008:
SELECT ISNULL(MAX(X), 0) AS MaxX
FROM tbl WHERE XID = 1