Link to home
Start Free TrialLog in
Avatar of rlewisc
rlewisc

asked on

SQL scripting help

I am an expert in a few things but SQL scripting is not one of them.  That being said, here is what I need help with.  There are three fields in a table that I need to manipulate.  These fields are EMP_ID, EARN_ID, and Amount.  There are multiple records in the table for each EMP_ID with different EARN_ID and Amount.  There is one record for each EMP_ID that has an EARN_ID equal to 'W2MEDREV'.  Each EMP_ID record will also have and EARN_ID record for their status (i.e. single, married, etc.).  I need to produce a script that will set the Amount field in the record for each EMP_ID that contains the 'W2MEDREV' field to the negative or inverse of the Amount in the single, married, etc. for the corresponding EMP_ID.

EMP_ID        EARN_ID             Amount
00001           W2MEDREV        100.00
00001           MARRIED           -100.00
00002           W2MEDREV         200.00
00002           SINGLE               -200.00

This is a sample of what I need to end up with.  Can someone help me?  

Thanks.......
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg 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
SOLUTION
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 rlewisc
rlewisc

ASKER

I utilized both comments.  It worked perfectly.  Thanks for the help.....