HackerRank TOP 20 SQL Interview 7. Salary Review — MAANG question
Time to complete — 29 minutes
Question Type = Medium
Asked in = Microsoft, Uber, Lyft, Bloomberg, Morgan Stanley, Apple, and Google.
Skills: PLSQl, loop statements, control structures, using explicit cursors
Insights — It should be read very carefully read and you must ask questions in between.
Question —
Write a PL/SQL block to increment Employees’ salaries by 10% with the following exceptions:
- If the salary is already above the maximum salary for the employee’s grade, the salary remains unchanged.
- If the increment would take the salary above the maximum salary for the employee’s grade, the salary is set at the maximum salary for the grade.
Display employee ID, employee name, current salary, and new salary each separated by a single space. Sort the results ascending by employee ID.
Job Grade Table
Store the job grade table into a collection variable.
Schema
There is 1 table: EMPLOYEES.