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

方法1:distinct+order by
select distinct salary
from salaries
where to_date='9999-01-01'
order by salary desc;

方法2:distinct+order by
select salary
from salaries
where to_date='9999-01-01'
group by salary
order by salary desc;
补充:WHERE语句在GROUP BY语句之前,SQL会在分组之前计算WHERE语句。HAVING语句在GROUP BY语句之后,SQL会在分组之后计算HAVING语句。

说明:
对于distinct与group by的使用:
1.当对系统的性能高并且数据量大时使用group by
2.当对系统的性能不高时或者使用数据量少时两者借口
3.尽量使用group by