Replace empty values as 0 instead of null while joining two tables in sql
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…..
2 Solutions collect form web for “Replace empty values as 0 instead of null while joining two tables in sql”
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
COALESCE function which automatically replace
null values as
SELECT COALESCE(total_amount, 0) from #Temp1