Link to home
Start Free TrialLog in
Avatar of gpsdh
gpsdh

asked on

SQL - Add negative sign if matlfer.xtype = 'INVSUB'

 SELECT 
        CASE matlxfer.xtype
          WHEN 'ADDINV' THEN '552'
          WHEN 'INVSUB' THEN '551'
        END AS ADJUSTMENT ,
             matlxfer.xfer_qty 

Open in new window


Add negative sign if matlfer.xtype = 'INVSUB'
Data

 matlfer.xtype matlxfer.xfer_qty
ADDINV   1
INVSUB  2
ADDINV 3
INVSUB  4

Open in new window


Our database doesn't have negatives, but I need to send data with them and i've tried variables and other things, but none have worked as I wanted.  Basically I need it to show as this.

matlxfer.xfer_qty
1
-2
 3
-4

Open in new window


Thanks
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gpsdh
gpsdh

ASKER

That works!  Thanks!
btw I have an article out there on SQL Server CASE Solutions that has a wompload of CASE examples.  Hit the 'Yes' button if it helps you out.

Thanks for the grade.  Good luck with your project.  -Jim