【數據庫】找出所有員工當前薪水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));

思路:
可以用distinct或者goup by方法

代碼:

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

group by 方法
select salary from salaries where to_date='9999-01-01' group by salary order by salary DESC

**輸出描述: **

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章