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.

      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_code            varchar
      Job_title                  varchar
      Exempt_non_exempt_status  bit         (1-Exempt, 0-non-Exempt)      
      Minimum_salary            money
      Maximum_salary            money

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Patrick MatthewsCommented:
Hi mayan1,

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


  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)
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

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' )
Patrick MatthewsCommented:

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


Patrick MatthewsCommented:

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
        THEN Employee.Salary * 1.1
    Join Job_Title On Employee.Job_Title_Code = Job_Title.Job_Title_Code
WHERE Employee.Job_title_code = 'foo'


Patrick MatthewsCommented:

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


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.
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.
mike  it is a marvelous idea to do a 10% across the board
me too ;-)
At least if SQL is in the title somewhere. Anyway my apologies for the off-topicness.
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.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.