The document contains 25 questions related to writing SQL queries to retrieve employee and department data from database tables. The questions cover basic queries to retrieve employee names, departments, dates joined, salaries, as well as more complex queries involving calculations, conditions, aggregations and updates.
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0 ratings0% found this document useful (0 votes)
72 views4 pages
Practical Assignment of Dbms
The document contains 25 questions related to writing SQL queries to retrieve employee and department data from database tables. The questions cover basic queries to retrieve employee names, departments, dates joined, salaries, as well as more complex queries involving calculations, conditions, aggregations and updates.
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4
Assignment Questions
1. Write a query in SQL to display the first name, last name,
department number, and department name for each employee. Select employees.first_name,employees.last_name, employees.department_id,departments.department_na me from employees,departments where employees.department_id=departments.department_id;
2. Write a query in SQL to display the first name, last name,
department number and department name, for all employees for departments 80 or 40. Selectemployees.first_name,employees.last_name, employees.department_id,departments.department_na me from employees,departments where employees.department_id in(80,40); 3. Write a query in SQL to display those employees who contain a letter z to their first name and also display their last name, department, city, and state province. select employees.first_name,employees.last_name,departmen ts.department_name,emp_details_view.city,emp_details _view.state_province from employees,departments,emp_details_view where employees.department_id=emp_details_view.departme nt_id; 4. Display first name and join date of the employees who is either IT Programmer or Sales Man. select employees.first_name,employees.hire_date from employees,departments where employees.department_id=departments.department_id and departments.department_name in('IT','Sales'); 5. Display employees who joined in the month of may. select employees.first_name,employees.hire_date from employees where extract(month from hire_date)=5; 6. Display first name and experience of all employees. select first_name,hire_date,round((sysdate- hire_date)/365) from employees; 7. Display average salary of employees in each department who have commission percentage.
select department_name,round(avg(salary)) from
employees,departments where commission_pct is not null group by department_name;
8. Display number of employees joined after 15th of the
month.
9. Change salary of employee 115 to 8000 if the existing
salary is less than 6000.
10. Display department name and number of employees in
the department. 11. Display details of jobs that were done by any employee who is currently drawing more than 15000 of salary. 12. Display department name, manager name, and salary of the manager for all managers whose experience is more than 5 years. 13. Display employee name and country in which he is working. 14. Display details of departments in which the maximum salary is more than 10000. 15. Display details of departments managed by ‘Smith’. 16. Display the city of employee whose employee ID is 105. 17. Display the details of employees drawing the highest salary in the department. 18. Display the department number and department name for all departments located in Toronto 19. Display the first name, salary, and department number for all employees who earn more than the average salary. 20. Display the first name, salary and department number for all employees who work in the department as employee number 124 PL/SQL 21. Increase the salary of employee 115 based on the following conditions: If experience is more than 10 years, increase salary by 20% If experience is greater than 5 years, increase salary by 10% Otherwise 5% Case by Expression: 22. Find out the name of the employee and name of the department for the employee who is managing for employee 103. 23. Change commission percentage as follows for employee with ID = 150. If salary is more than 10000 then commission is 0.4%, if Salary is less than 10000 but experience is more than 10 years then 0.35%, if salary is less than 3000 then commission is 0.25%. In the remaining cases commission is 0.15%. 24. Update salary of an employee based on department and commission percentage. If department is 40 increase salary by 10%. If department is 70 then 15%, if commission is more than .3% then 5% otherwise 10%. 25. Write a program to interchange the salaries of employee 120 and 122.