I have join two tables t1 and t2. The output produces some null records since there is no data in the table t2. Instead of showing null I want to show 0 since I have to perform some arithmetic operation in the crystal reports. please help me.....
Asked
Active
Viewed 1,381 times
1
-
5ISNULL(t2.col1,0) it will do the trick – mohan111 May 13 '16 at 07:15
-
http://stackoverflow.com/questions/7930810/sql-replace-all-nulls this link also has the solution. – Akash Amin May 13 '16 at 07:24
2 Answers
1
sample example
declare @t table (ID int)
declare @t1 table (ID int)
insert into @t (id) values (1)
select t.ID,ISNULL(TT.ID,0)id from @t t
LEFT JOIN @t1 tt
ON t.ID = tt.ID

mohan111
- 8,633
- 4
- 28
- 55
1
Use the COALESCE
function which automatically replace null
values as 0
.
Sample
SELECT COALESCE(total_amount, 0) from #Temp1

A_Sk
- 4,532
- 3
- 27
- 51

DataScientYst
- 442
- 2
- 7
- 19