• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

Increase Employees salaries


I am trying to Choose a job_title_code: Increase all employees’ salaries that have: job_title_code by 10%
Here are the tables involved.


Employee
      Social_security_number      char
      Last_name                  varchar
      First_name                  varchar
      Address                  varchar
      City                        varchar
      State                  char
      Zip_code                  char
      Telephone_area_code      char            
      Telephone_number            char      
      Email_address            varchar      
      Job_title_code            varchar      
      Hire_date                  smalldatetime
      Salary                  money
                        
Job_title
      Job_title_code            varchar
      Job_title                  varchar
      Exempt_non_exempt_status  bit         (1-Exempt, 0-non-Exempt)      
      Minimum_salary            money
      Maximum_salary            money

1
mayan1
Asked:
mayan1
1 Solution
 
TimCotteeCommented:
Hi mayan1,

Update Employee Set Salary = Salary * 1.1 From Employee Inner Join Job_Title On Employee.Job_Title_Code = Job_Title.Job_Title_Code

Should do it, remember though to take a backup first in case anything goes wrong!

Tim Cottee
0
 
Patrick MatthewsCommented:
Hi mayan1,

UPDATE Employee
SET Salary = Salary * 1.1
WHERE Job_title_code = 'foo'

Regards,

Patrick
0
 
MikeWalshCommented:
UPDATE e
  SET e.Salary = e.Salary + (0.10 * e.salary)
 FROM Employee E
   JOIN job_Title jt
    ON e.Job_Title_Code = jt.Job_Title_code
 WHERE jt.Job_Title = 'SQL DBA' (or whatever title you want)
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
update employee
   set salary * 1.1
where job_title_code = 'your_title_code'
 

or, if you have the title:

update employee
   set salary * 1.1
where job_title_code in ( select job_title_code from job_title where job_title =  'your_title' )
0
 
Patrick MatthewsCommented:
mayan1,

You did not mention it, but does there have to be a check that the new salary not be more than the max salary?

Regards,

Patrick
0
 
Patrick MatthewsCommented:
mayan1,

If you need to check against the max salary...

UPDATE Employee
SET Employee.Salary = (CASE
    WHEN (Salary * 1.1) > Job_title.Maximum_salary
        THEN Job_title.Maximum_salary
    ELSE
        THEN Employee.Salary * 1.1
    END)
FROM Employee INNER JOIN
    Join Job_Title On Employee.Job_Title_Code = Job_Title.Job_Title_Code
WHERE Employee.Job_title_code = 'foo'


Regards,

Patrick
0
 
Patrick MatthewsCommented:
Lowfatspread,

Sorry, I did not see your admin comment before my last post...

Regards,

Patrick
0
 
MikeWalshCommented:
Lowfat - just out of curiosity, what gave the clue that it was a homework question? The 10% increase? I wasn't even thinking of that possibility when I answered.
0
 
MikeWalshCommented:
I hear you. I think it is a marvelous idea to do a 10% across the board for all in my title though. Anyway I agree with your point here and will look for those examples more before replying moving forward.
0
 
LowfatspreadCommented:
mike  it is a marvelous idea to do a 10% across the board
me too ;-)
0
 
MikeWalshCommented:
At least if SQL is in the title somewhere. Anyway my apologies for the off-topicness.
0
 
mayan1Author Commented:
I was checking on proposed solutions. The homework has been done and turned in. I got several wrong and wanted to know the correct way to handle in the future.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now