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.......
Microsoft SQL Server

Avatar of undefined
Last Comment
rlewisc
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of rlewisc
rlewisc

ASKER

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

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo