原题链接
1.order by+distinct去重
select distinct salary from salaries
where to_date='9999_01_01'
order by salary desc;
order by 用于排序,一般与asc升序或desc降序一起使用(默认升序).
例:select * from table order by column desc;(表示根据column降序查询)
group by 用于分类汇总,一般与聚合函数(比如avg平均、sum合计、max最大、min最小、count计算行)一起使用。还可以有去重的作用。
例:select month,sum(salary)as total_salary from salarytable group by month;
2.group by方法
select salary from salaries
where to_date='9999_01_01'
group by salary
order by salary desc;