PL/SQL Cursor Exercises: Print the department name, head of the department, city and number of employees are wroking in that department
PL/SQL Cursor: Exercise-43 with Solution
Write a block in PL/SQL to print the department name, head of the department, city and number of employees are wroking in that department.
Sample Solution:
Table: employees
employee_id integer first_name varchar(25) last_name varchar(25) email archar(25) phone_number varchar(15) hire_date date job_id varchar(25) salary integer commission_pct decimal(5,2) manager_id integer department_id integer
Table: departments
department_id integer department_name varchar(25) manager_id integer location_id integer
PL/SQL Code:
Sample Output:
SQL> / Department Name Department Head Head Office Number of Employees ---------------------------------------------------------------------------------------- Administration Jennifer Seattle 1 Marketing Michael Toronto 2 Purchasing Den Seattle 6 Human Resources Susan London 1 Shipping Adam South San Francisco 45 IT Alexander Southlake 5 Public Relations Hermann Munich 1 Sales John Oxford 34 Executive Steven Seattle 3 Finance Nancy Seattle 6 Accounting Shelley Seattle 2 PL/SQL procedure successfully completed.
Flowchart:


Improve this sample solution and post your code through Disqus
Previous: Write a block in PL/SQL to display the first name, job title and start date of employees.
Next: Write a block in PL/SQL to print the specifc number of rows from a table.
What is the difficulty level of this exercise?