/*
As a Data Analyst, your task is to identify the employees with the minimum and maximum overtime hours in the company.
This information will help the organization determine appropriate holiday allocations for each employee based on their workload.
Schema:
Table Name: Employee_Overtime
| Column Name | Data Type | Description |
|----------------|--------------|---------------------------------------------|
| employee_name | VARCHAR(50) | Name of the employee |
| hours | INT | Total overtime hours worked by the employee |
Task:
1. Display all employees' overtime hours.
2. Find the employee with the least overtime hours and employee with the most overtime hours.
3. Include the following columns in the output:
- employee_name
- hours
- least_overtime_employee
- most_overtime_employee
Expected Output:
| employee_name | hours | least_overtime_employee | most_overtime_employee |
|---------------------|-------|-------------------------|------------------------|
| Steve Patterson | 29 | Steve Patterson | Mary Patterson |
| Diane Murphy | 37 | Steve Patterson | Mary Patterson |
| Jeff Firrelli | 40 | Steve Patterson | Mary Patterson |
| Gerard Bondur | 47 | Steve Patterson | Mary Patterson |
| Loui Bondur | 49 | Steve Patterson | Mary Patterson |
| William Patterson | 58 | Steve Patterson | Mary Patterson |
| Barry Jones | 65 | Steve Patterson | Mary Patterson |
| Foon Yue Tseng | 66 | Steve Patterson | Mary Patterson |
| Anthony Bow | 66 | Steve Patterson | Mary Patterson |
| Gerard Hernandez | 66 | Steve Patterson | Mary Patterson |
| Mary Patterson | 74 | Steve Patterson | Mary Patterson |
*/
CREATE TABLE Employee_Overtime (
employee_name VARCHAR(50),
hours INT
);
INSERT INTO Employee_Overtime (employee_name, hours) VALUES
('Steve Patterson', 29),
('Diane Murphy', 37),
('Jeff Firrelli', 40),
('Gerard Bondur', 47),
('Loui Bondur', 49),
('William Patterson', 58),
('Barry Jones', 65),
('Foon Yue Tseng', 66),
('Anthony Bow', 66),
('Gerard Hernandez', 66),
('Mary Patterson', 74);
SELECT
employee_name,
hours,
FIRST_VALUE(employee_name) OVER (ORDER BY hours ASC) AS least_overtime_employee,
FIRST_VALUE(employee_name) OVER (ORDER BY hours DESC) AS most_overtime_employee
FROM
Employee_Overtime;
To embed this program on your website, copy the following code and paste it into your website's HTML: