查詢每個部門分別是哪個員工獲得了其所在部門的最高工資

時間 2022-01-17 11:20:08

1樓:來自海州灣有衝勁的太平花

獲取所有部門中當前(dept_emp.to_date = '9999-01-01')員工當前(salaries.to_date='9999-01-01')薪水最高的相關資訊,給出dept_no, emp_no以及其對應的salary,按照部門編號升序排列。

create table `dept_emp` (

`emp_no` int(11) not null,

`dept_no` char(4) not null,

`from_date` date not null,

`to_date` date not null,

primary key (`emp_no`,`dept_no`));

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`));

如插入:

insert into dept_emp values(10001,'d001','1986-06-26','9999-01-01');

insert into dept_emp values(10002,'d001','1996-08-03','9999-01-01');

insert into dept_emp values(10003,'d001','1996-08-03','1997-08-03');

insert into salaries values(10001,90000,'1986-06-26','1987-06-26');

insert into salaries values(10001,88958,'2002-06-22','9999-01-01');

insert into salaries values(10002,72527,'1996-08-03','1997-08-03');

insert into salaries values(10002,72527,'2000-08-02','2001-08-02');

insert into salaries values(10002,72527,'2001-08-

2樓:匿名使用者

select a.員工名,a.部門號,max(b.

工資數) from emp a,dept b where a.部門號 = b.部門號 group by a.

部門號;

3樓:易水寒潭

思路:先求出每個部門的最高工資,再與原表做內連線,只要滿足最高工資與原表的工資相等的過濾條件即可

select e.ename,e.sal,e.deptnofrom emp e join (select deptno,max(sal) max_sal

from emp

group by deptno) d

on e.deptno=d.deptno

where e.sal=d.max_sal

在oracle中怎麼查詢每個部門最高工資的員工編號

4樓:

select empno from emp where sal in (select max(sal) from emp group by deptno)

這是oracle中自帶的幾張表,emp表代表員工表,換成你自己的表即可

5樓:匿名使用者

select staff_number

from (select staff_number,rank() over(partition by department order by salary desc) rn --更具部門分組排序。

from table_name) tnwhere rn = 1

也可以取每個部門最高工資前n位

6樓:匿名使用者

select 員工編號

from tab t

where not exists (select 1 from tab where 部門 = t.部門 and 工資 > t.工資)

7樓:我又強力了

select emp.empno ,emp.sal ,emp.

deptno,a.msal from emp,(select max(sal) msal ,deptno from emp group by deptno) a where emp.sal=a.

msal and a.deptno=emp.deptno;

查詢出每個部門中工資最高的職工怎麼查?

8樓:匿名使用者

excel中查詢出每個部門中工資最高的職工的公式是select empno, empname where sal in (select max(sal) from emp group by deptno)。

sql語句公式如下:

其中,empno是員工編號,同時也是該表的主鍵,ename是員工姓名,sal是員工工資,deptno是員工部門。

如何找出每個部門的最高工資的員工資訊呢?

常用的方法是關聯查詢,sql語句如下:

結果如下:

查出每個部門大於平均工資的員工姓名,所在部門名稱,工資的sql語句怎麼寫

oracle hr賬戶下如何查詢顯示每個部門工資最低的員工的部門名稱、工作城市、工資、及入職時間 等。

9樓:匿名使用者

select 姓名,部門名稱,工作城市,工資,入職時間 from (select 部門,min(工資) salary from 表 group by 部門) a,表 b where a.salary=b.工資

請把漢字內容改成你的欄位名稱。 裡面用到的兩個表同為hr的表。如果是幾個表的綜合,你可以把他們聯到一起,如:

(select a.姓名,b.部門名稱,b.

工作城市,c.工資,a.入職時間 from 員工表 a,部門表 b,工資表c where a.

部門id=b.部門id and a.員工id=c.

員工id)

括號裡的內容可以替換第一句的"表"字.如果你一個表中有所有內容,直接用你的這一個表名即可。

10樓:匿名使用者

select * from table as t1 where(select count(*) from table as t2 where t1.部門=t2.部門)<=1

11樓:匿名使用者

還沒說有啥表那 幾個

如何在oracle中查詢出每個部門中工資最高的職工。

12樓:杞寄文

select a.員工名,a.部門號,b.工資數 from emp a,dept b where a.部門號 = b.部門號;

「坦克世界」的每個系分別是哪個國家的?

坦克世界 國服版目前有蘇聯 s系 德國 d系 美國 m系 英國 y系 法國 f系 中國 c系 日本 r系 捷克 j系 瑞典 v系 的9類戰車可供玩家選用。一 蘇聯 s系 標誌 紅。s系 蘇聯。d系 德國。y系 英國。m系 美國。r系 日本。c系 中國。f系 法國。就這麼多了 應該沒漏掉的了。坦克世界...

哪個省的公務員工資最高,哪個部門的公務員工資最高,是多少

諾言 公務員由於等級不同而有著不同的收入待遇。我國公務員具體收入及差距情況有其國情特點。以下是對全國各地 部委和32個省區市 貼出的公務員工資情況進行了整理 因為都是網上大家貼出的,不保證真實性 基本都是最近幾年的,可以供想考公務員的同學參考。部委機關公務員工資,一般進去後也就7000,轉正後能有8...

香港警隊有多少部門,分別是什麼

丁 部 門 監 管 處 資 訊 系 統 部 資 訊 系 統 部 總 部 資 訊 系 統 部 總 部 轄 下 各 課 在 資 訊 系 統 部 擔 任 重 要 及 決 策 的 角 色 負 責 統 籌 資 訊 系 統 部 所 有 與 資 訊 科 技 保 安 及 審 計 行 政 財 務 策 劃 人 事 及 ...