[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL set null values to 0

Posted on 2011-05-04
2
Medium Priority
?
251 Views
Last Modified: 2012-05-11
Hi,

I have a query that calculates the total number of overtime hours a person worked for daily.  If the person did not work overtime, I get a result of "NULL".  How can I change this value to "0"?

Here is the part of the query that gives me the total hours worked per day:

TotalHours = Cast(substring( convert(varchar(10), dateadd(second,  sum(datediff(second, ClockIn, ClockOut)), 0),
108) , 1,2) + '.' + Cast((Cast(substring(convert (varchar(10), dateadd(second, sum(datediff(second, ClockIn, ClockOut)),
 0), 108) ,4,2) as Int) * 10)/6 as varchar(4)) as decimal(4,2)),
0
Comment
Question by:NerishaB
2 Comments
 
LVL 10

Accepted Solution

by:
Asim Nazir earned 2000 total points
ID: 35688196
Try isnull(column, 0)
0
 

Author Closing Comment

by:NerishaB
ID: 35688227
cool, thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

872 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