Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
8.找出所有员工当前薪水salary情况.md 522 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 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的作用

Comment ( 0 )

Sign in for post a comment