Hi,@nononame2021
Welcome to Microsoft T-SQL Q&A Forum!
Please check this:
DECLARE @test_table TABLE
(
ID nvarchar not null,
expected_amount nvarchar(25) NULL,
actual_amount nvarchar(25) NULL
)
INSERT INTO @test_table VALUES
( 1, 0, 17.5)
select case when cast (cast ([actual_amount] as float) as money) - cast (cast ([expected_amount] as float) as money) < 0
then cast((cast (cast ([actual_amount] as float) as money) - cast (cast ([expected_amount] as float) as money))as nvarchar)
else ''
end as test from @test_table;
Output:
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.