Bonus_amount Number Not null 10 Bonus_date Date *Worker_Ref_ID is Foreign Key with reference to Worker_ID of Worker Table Worker_Ref_ID Bonus_amount Bonus_date 001 5000 16-mar-20 002 3000 16-jun-11 003 4000 16-mar-20 001 4500 16-mar-20 002 3500 16-jun-11
Title table:
Name Data Type Constraint Size
Worker_Ref_ID Number Foreign Key*
Worker_title Varchar2 Not null 25 Affected_from Date *Worker_Ref_ID is Foreign Key with reference to Worker_ID of Worker Table
Worker_Ref_ID Worker_title Affected_from
001 Manager 20-feb-20 002 Executive 16-jun-11 008 Executive 16-jun-11 005 Manager 16-jun-11 004 Asst. Manager 16-jun-11 007 Executive 16-jun-20 006 Lead 16-jun-11 003 Lead 16-jun-20 1. Write sql queries for below questions: a. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘h’ and contains six alphabets. b. Write an SQL query to print the FIRST_NAME from Worker table after replacing ‘a’ with ‘A’. c. Write an SQL query to print details for Workers with the first name as “Vipul” and “Satish” from Worker table. d. Write an SQL query to print details of workers excluding first names, “Vipul” and “Satish” from Worker table. e. Write an SQL query to fetch departments along with the total salaries paid for each of them.
2. Write sql queries:
a. Write an SQL query to show only odd rows from a table. b. Write an SQL query to show only even rows from a table. c. Write an SQL query to show the second highest salary from worker table. d. Write an SQL query to fetch the first 50% records from a table. e. Write an SQL query to fetch the departments that have less than five people in it.
3. Write sql queries:
a. Write an SQL query to show the last record from a table. b. Write an SQL query to fetch the first row of a table. c. Write an SQL query to fetch the names of workers who earn the highest salary. d. Write an SQL query to fetch the no. of workers for each department in the descending order. e. Write an SQL query to fetch worker names with salaries >= 50000 and <= 100000. Q4 to Q6 will use the following 3 tables:
Department table:
Name Data Type Constraint Size
Dep_id Number Primary Key
Dep_name Varchar2 20 Dep_location Varchar2 15
Dep_id Dep_name Dep_location
1001 Finance Sydney 2001 Audit Melbourne 3001 Marketing Perth 4001 Production Brisbane
Emp_name Varchar2 15 Job_name Varchar2 10 Manager_id Number Hire_date Date Salary Number 10,2 Commission Number 7,2 Dep_id Number Foreign Key* *Dep_id is Foreign Key with reference to Dep_id of department table.
65646 Jonas Manager 68319 02-04-91 2957.00 2001 67858 Scarlet Analyst 65646 19-04-97 3100.00 2001 69062 Frank Analyst 65646 03-12-91 3100.00 2001 63679 Sandrine Clerk 69062 18-12-90 900.00 2001 64989 Adelyn Salesman 66928 20-02-91 1700.00 400.00 3001 65271 Wade Salesman 66928 22-02-91 1350.00 600.00 3001 66564 Madden Salesman 66928 28-09-91 1350.00 1500.00 3001 68454 Tucker Salesman 66928 08-09-91 1600.00 0.00 3001 68736 Adnres Clerk 67858 23-05-97 1200.00 2001 69000 Julius Clerk 66928 03-12-91 1050.00 3001 69324 Marker Clerk 67832 23-01-92 1400.00 1001 4. Write sql queries a. Write a query to count the no. of characters without considering the spaces for each employee name. b. List all the employees who joined before 1991. c. List the name of employees and their manager separated by the string ‘works for’. For example, Blaze works for Kayling. d. List the employee name and job_name who are not working under a manager. e. List employee id, name along with department name.
5. Solve the below questions
a. List the name, job name, manager id, salary, manager name, manager’s salary for those employees whose salary is greater than the salary of their managers. b. List the employees name, department, salary and commission. For those whose salary is between 2000 and 5000 while location is PERTH. c. List the employees who are working either MANAGER or ANALYST with a salary range between 2000 to 5000 without any commission. d. List the employees who are senior to their own managers (those employees who were hired before their managers). e. List the id, name, monthly salary, daily salary of all the employees in the ascending order of their annual salary.
6. Solve the queries:
a. Write a query to display the location of CLARE. b. List the employees in ascending order of the salary whose annual salary is below 25000. c. Display the number of employees for each job in each department. d. List total number of managers and clerks. e. Calculate minimum, maximum, average and total salary from employees table.