Task: UPDATE all employees salary in department 40 or 60 depending on their current salary range. Create a cursor and load all the records belongs to employees who works in department either in 40 or 60
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Please use sql to answer the follwoing question (an erd has also been add)
Task 2:
- Task: UPDATE all employees salary in department 40 or 60 depending on their current salary range.
Create a cursor and load all the records belongs to employees who works in department either in 40 or 60
- a) Include employee_id, last_name, department_id and salary in Cursor SELECT
Cursor cur_emp1 IS
SELECT employee_id, last_name, department_id, salary FROM EMPLOYEES
WHERE department_id IN (40,60);
- b) Now inside BEGIN and END block
create CURSOR FOR LOOP with k keyword.
FOR k IN cur_emp1
LOOP
END LOOP;
- now inside above for loop check each records salary
IF
If employee salary is less than 5000 then add 20% of their salary and update actual phsyical table
update employees SET salary= salary*1.20
WHERE employee_id = k.salary;
Else if if employee salary is less then 8000 add 15%
update employees SET salary= salary*1.15
WHERE employee_id = k.salary;
everything else THEN add 10% to their salary .. change their salary in the actual table.
END IF;
Step by step
Solved in 2 steps