A MySQL table named 'Employ' was created to store employee data, including fields for ID, name, salary, address, working date, and working hours. Five employee records were inserted, and various queries were executed to retrieve counts of employees by address, total and average working hours per employee, and a filtered list of employees with total working hours greater than 20. The results show employee distribution across different cities and highlight Employee 5 as the one with the highest working hours.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views
Assignment 4
A MySQL table named 'Employ' was created to store employee data, including fields for ID, name, salary, address, working date, and working hours. Five employee records were inserted, and various queries were executed to retrieve counts of employees by address, total and average working hours per employee, and a filtered list of employees with total working hours greater than 20. The results show employee distribution across different cities and highlight Employee 5 as the one with the highest working hours.
+------+------------+---------+---------------+--------------+---------------+ | e_id | e_name | salary | address | working_date | working_hours | +------+------------+---------+---------------+--------------+---------------+ | 1001 | Employee 1 | 5000.00 | New York | 2023-09-01 | 18 | | 1002 | Employee 2 | 6000.00 | Los Angeles | 2023-09-01 | 9 | | 1003 | Employee 3 | 5500.00 | Chicago | 2023-09-02 | 20 | | 1004 | Employee 4 | 7000.00 | San Francisco | 2023-09-02 | 13 | | 1005 | Employee 5 | 6500.00 | New York | 2023-09-03 | 32 | +------+------------+---------+---------------+--------------+---------------+ 5 rows in set (0.00 sec)
mysql> SELECT address, COUNT(*) AS city_count
-> FROM Employ -> GROUP BY address; +---------------+------------+ | address | city_count | +---------------+------------+ | New York | 2 | | Los Angeles | 1 | | Chicago | 1 | | San Francisco | 1 | +---------------+------------+ 4 rows in set (0.00 sec)
mysql> SELECT e_name, SUM(working_hours) AS total_working_hours