1 Star 0 Fork 146

hzcloud / 数据库SQL实战

forked from xuthus / 数据库SQL实战 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
8.找出所有员工当前薪水salary情况.md 522 Bytes
一键复制 编辑 原始数据 按行查看 历史
xuthus 提交于 2019-08-13 08:38 . revise:content revision

找出所有员工当前薪水salary情况

题目描述

找出所有员工当前(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的作用

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
SQL
1
https://gitee.com/mentas/Database-SQL-Actual-Combat.git
git@gitee.com:mentas/Database-SQL-Actual-Combat.git
mentas
Database-SQL-Actual-Combat
数据库SQL实战
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891