题目描述

找出所有员工当前(to_date='9999-01-01')具体的薪水salary情况,对于相同的薪水只显示一次,并按照逆序显示

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`));

答案

select DISTINCT salary from salaries where to_date = '9999-01-01' order by salary desc

解析

没有新知识
去除重复:DISTINCT
子句执行顺序from -> where -> group by -> having -> select -> order by


醉后不知天在水,满船清梦压星河