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.
| Author |
Topic |
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-05-06 : 06:33:36
|
| on my query there is a left join and with this there comes null values in some columns.But i want to change null values to 0i tries this bit it give me the wrong resultcase when sum(Money) is null then 0 endthe query above sets all numeric values to null and all null values to 0 why??how can i set null values to 0MS BLESS US |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-06 : 06:37:50
|
| Select IsNull(Money,0) From TblnameIf Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-05-06 : 06:47:34
|
| nicethxMS BLESS US |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-05-06 : 07:03:08
|
| count(IsNull(Word,0))ok that works but count result comes "1" when there is no resultif there are 5 words it counts normally but if there is no word it counts it as 1 why ?my query is like this.Select t1.ID,t1.UserName,t1.corpName,count(IsNull(t2.Word,0))wordcount,sum(isNull(money,0)) totalmoney,sum(IsNull(money2,0))money2 from tbl_a t1 left join tbl_b t2 on t2.ID = t1.IDgroup by t1.ID,t1.UserName,t1.corpNameon tbl_a there are corporations and informations about themon tbl_b there are words that bought by corporatoinsand my query gets a short information about them (wordcount,totalmoney...like that)but why count comes as 1?when a corp bought one word it counts as 1 ok that is rgihtbut when there is no it counts as 1 too.MS BLESS US |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-06 : 07:17:03
|
| can you post the same data from the table.. since i dont think you require to use isnull function for the counting the records.If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-05-06 : 07:43:03
|
| tbl_aID Corp1 jack2 Joe3 jessytbl_bskbID Word Corp Money ID18 AMD jack 3 119 ATI jack 3 120 Intel joe 1 2and result will count how many words each copr have (but all corp. so i used left join) total money ( i get this correctly( my problem is only countMS BLESS US |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-06 : 08:02:03
|
change thiscount(IsNull(t2.Word,0))wordcount tocount(t2.Word)wordcount KH |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-05-06 : 08:09:39
|
| oh damnyeah rightok thx againMS BLESS US |
 |
|
|
|
|
|
|
|