Solved

Syntax for adding a number to a null in Table Column

Posted on 2008-10-20
1
213 Views
Last Modified: 2012-05-05
I need the syntax to add say the number 5 to a column in a table that is <NULL>.  It keeps returning null instead of 5.
0
Comment
Question by:N R
1 Comment
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 22762638
This should do it
select coalesce(my_column,0) + 5
from my_table

Open in new window

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Solar Winds can't see SQL Server Express 17 38
Help with Oracle IF statment 5 27
SQL R 21 29
too many installs coming along with SQL 2016? 1 18
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question