Reputation: 31643
I want to select a max value from a table:
SELECT MAX(cid) FROM itemconfiguration;
However, when table itemconfiguration
is empty the MAX(cid)
statement is evaluated to NULL
while I need a number. How can I handle this and treat NULL
as 0
?
Upvotes: 30
Views: 38092
Reputation: 11
Can replace a number when max return null using ISNULL ,
ISNULL(MAX(cid),0) FROM itemconfiguration;
Upvotes: 1