Each employee can have up to 5 records (5 PayCodes)I need to ensure each employee : their payamt of PayCode 2 =1.5 * PayAmt of PayCode 1.
Example Table:
For example:
EmpID PayCode PayAmt
123 1 10
123 2 15
456 1 9
789 3 6500
851 4 40000
333 5 1400
777 1 6.5
777 2 8
109 1 5.8
109 2 8.7
For example, EmpID 777 as PayAmt $8 under PayCode2, , but it should be 9.75 (1.5 times of 6.5 - PayAmt in Paycode 1).
So, I want to have an UPDATE statement to Set every employee whose PayAmt of PayCode=2 equal to 1.5*PayAmt of PayCode=1.
HOW CAN I DO THAT IN T-SQL? Please help. Thank you.