Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Nulls on left join to 0

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-02-19 : 06:02:30
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-19 : 06:07:13
COALESCE( t1.ColName, 0)

t1 is alias for Left Side Table

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-19 : 06:17:10
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

550 Posts

Posted - 2013-02-19 : 06:17:59
excellent. thank you very much.

so simple
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-02-19 : 06:28:55
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
   

- Advertisement -