sql is null then 0 else 1 end as meaning code example
Example: store case result sql
declare
@val int = 0;
select
@val = CASE
WHEN MONTH([DATE]) = MONTH(getdate()) AND
YEAR([DATE]) = YEAR(getdate())
THEN SUM(PROFIT)
OVER (PARTITION BY [Name],
MONTH([DATE]), YEAR([DATE]))
ELSE 0
END
FROM table_name
WHERE [Name] = @Name AND
MONTH([DATE]) = @Month AND
YEAR([DATE]) = @Year
print @val