-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTop Earners.sql
More file actions
24 lines (20 loc) · 862 Bytes
/
Top Earners.sql
File metadata and controls
24 lines (20 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* The Employee table containing employee data for a company is described as follows:
+-------------+----------+
| Column | Type |
+-------------+----------+
| employee_id | int(11) |
| name | char(35) |
| months | char(35) |
| salary | int(11) |
+-------------+----------+
We define an employee's total earnings to be their monthly worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table.
Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings.
Then print these values as space-separated integers. */
--
-- Author: Pavith Bambaravanage
-- URL: https://github.com/Pavith19
--
SELECT MONTHS*SALARY AS earnings, COUNT(*) FROM employee
GROUP BY earnings
ORDER BY earnings DESC
LIMIT 1;