Hello,
I am pulling data through an ODBC, and am returning nulls with the below statement. How can I edit this SQL code so that if it returns a null, it converts it into a zero? I know I can use data cleansing, but it may slow down my process and wanted to have it written in the SQL code.
Sum(P.COGSAmount) as CostOfGoodsSold,
Thank you!
Solved! Go to Solution.
probably some thing around
if x is null then 0 else y
i sually use syntax something like this with case staement
case when field is null then 0 else field end as 'new_field)
so if you writing
select field1, field2, case when field1 is null then 0 else field end as 'new_field_name' from xyz where etc etc
Hi @kvrensanchez ,
You can use a COALESCE statement to set Nulls to Zero.
COALESCE(SUM(P.COGSAmount), 0) as CostOfGoodsSold,
Thank you! This was it.