SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Nulls on left join to 0
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masterdineen
Aged Yak Warrior

United Kingdom
545 Posts

Posted - 02/19/2013 :  06:02:30  Show Profile  Reply with Quote
Hello there.

i have a left join between two tables.

Is there a way.. for all the null values that appear due to no relationship, could that be canged to 0. I am already using a case statement, but still not changing them,

Regards

Rob

bandi
Flowing Fount of Yak Knowledge

India
2168 Posts

Posted - 02/19/2013 :  06:07:13  Show Profile  Reply with Quote
COALESCE( t1.ColName, 0)

t1 is alias for Left Side Table

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 02/19/2013 :  06:17:10  Show Profile  Reply with Quote
quote:
Originally posted by masterdineen

Hello there.

i have a left join between two tables.

Is there a way.. for all the null values that appear due to no relationship, could that be canged to 0. I am already using a case statement, but still not changing them,

Regards

Rob


Can you show your case statement?
Though you could use functions like ISNULL,COALESCE etc they all do CASE WHEN kind of check internally so even with CASE..WHEN it should work fine
Just being curious on what went wrong in your case
Anyways to avoid it you could use any of above functions

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

masterdineen
Aged Yak Warrior

United Kingdom
545 Posts

Posted - 02/19/2013 :  06:17:59  Show Profile  Reply with Quote
excellent. thank you very much.

so simple
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2168 Posts

Posted - 02/19/2013 :  06:28:55  Show Profile  Reply with Quote
quote:
Originally posted by masterdineen

excellent. thank you very much.
so simple

Welcome... Post your CASE statement also to know where that went wrong..

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000