snippetMinor
How do you handle adding nullable columns to each other in a query?
Viewed 0 times
eachyouhandlecolumnsqueryaddingnullablehowother
Problem
Currently whenever I write a query that is adding columns that can contain nulls I resort to wrapping each field in
Is there a better way to handle this, or is this the standard practice?
isnull or coalesce, such as coalesce(score1,0) + coalesce(score2,0).Is there a better way to handle this, or is this the standard practice?
Solution
Oracle provides NVL() for this scenario, ISNULL() is the equivalent in MS SQL Server. You could disguise all this in a VIEW to make your code clearer.
Context
StackExchange Database Administrators Q#1031, answer score: 4
Revisions (0)
No revisions yet.