Change numeric to negative if column condition is true

Hi,

My database field, trans_amt, is storing positive values for certain rows. I need to modify the query below to display it as negative in those cases where the check_no field is empty.

SELECT a.fund,a.key_orgn,a.account,a.trans_date,a.t_c,a.check_no,a.trans_amt,a.[description] as description
FROM transact a
WHERE a.account = @account AND a.trans_date >= @startdate and a.trans_date <= @enddate
ORDER BY a.trans_date desc

Your help is greatly appreciated. thank you.

Change
a.trans_amt ,
to
CASE WHEN a.check_no IS NULL THEN -a.trans_amt ELSE a.trans_amt END AS trans_amt ,

1 Like

Hey, thanks a lot. I was thinking a CASE statement did it.