SQL202. 找出所有员工当前薪水salary情况
描述
emp_no | salary | from_date | to_date |
10001 | 72527 | 2002-06-22 | 9999-01-01 |
10002 | 72527 | 2001-08-02 | 9999-01-01 |
10003 | 43311 | 2001-12-01 | 9999-01-01 |
salary |
72527 |
43311 |
示例1
输入:
drop table if exists `salaries` ; CREATE TABLE `salaries` ( `emp_no` int(11) NOT NULL, `salary` int(11) NOT NULL, `from_date` date NOT NULL, `to_date` date NOT NULL, PRIMARY KEY (`emp_no`,`from_date`)); INSERT INTO salaries VALUES(10001,72527,'2002-06-22','9999-01-01'); INSERT INTO salaries VALUES(10002,72527,'2001-08-02','9999-01-01'); INSERT INTO salaries VALUES(10003,43311,'2001-12-01','9999-01-01');
输出:
72527 43311
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3240KB, 提交时间: 2021-08-03
select salary from salaries group by salary order by salary desc;
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3260KB, 提交时间: 2021-08-01
select salary from salaries where to_date='9999-01-01' group by salary order by salary desc
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3300KB, 提交时间: 2020-11-22
select distinct salary from salaries where to_date='9999-01-01' order by salary desc
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3320KB, 提交时间: 2021-06-08
select salary from salaries where to_date="9999-01-01" group by salary order by salary desc
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3320KB, 提交时间: 2021-06-01
select salary from salaries group by salary order by salary desc