SQL架构 Employee 表包含所有员工。Employee 表有三列:员工Id,公司名和薪水。 +-----+------------+--------+ |Id | Company | Salary | +-----+------------+--------+ |1 | A | 2341 | |2 | A | 341 | |3 | A | 15 | |4 | A | 15314 | |5 | A | 451 | |6 | A | 513 | |7 | B | 15 | |8 | B | 13 | |9 | B | 1154 | |10 | B | 1345 | |11 | B | 1221 | |12 | B | 234 | |13 | C | 2345 | |14 | C | 2645 | |15 | C | 2645 | |16 | C | 2652 | |17 | C | 65 | +-----+------------+--------+
时间: 2023-03-29 10:02:00 浏览: 195
员工管理系统 SpringBoot + MyBatis-Plus + MySQL + BootStrap
请问,如何查询每个公司的最高薪水?
可以使用以下 SQL 语句查询每个公司的最高薪水:
SELECT Company, MAX(Salary) AS MaxSalary
FROM Employee
GROUP BY Company;
结果如下:
Company | MaxSalary
--------|----------
A | 15314
B | 1345
C | 2652
阅读全文