1

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.....

Venkatvasan
  • 491
  • 3
  • 13

2 Answers2

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