View difference between Paste ID: 7uR53xn0 and 4mn40RR4
SHOW: | | - or go back to the newest paste.
1
SELECT
2
  l.LAB_NAME,
3
  l.SALARY,
4
  d.DEP_NAME
5
FROM 
6
  LABORING l,
7
  DEPARTAMENT d,
8-
  
8+
  (SELECT 
9-
(SELECT
9+
    MAX(l.SALARY) AS SALARY_MAX 
10-
  d.DEP_ID,
10+
  FROM 
11-
  MAX(l.SALARY) AS SALARY_MAX
11+
    LABORING l,
12
    DEPARTAMENT d 
13-
  LABORING l, 
13+
  WHERE l.DEP_ID = d.DEP_ID 
14-
  DEPARTAMENT d
14+
    GROUP BY l.DEP_ID) sq
15-
WHERE l.DEP_ID = d.DEP_ID
15+
WHERE l.SALARY = sq.SALARY_MAX
16-
GROUP BY l.DEP_ID) sq
16+
  AND l.DEP_ID = d.DEP_ID