65012038

Date: 2020-11-25 20:15:56
Score: 4.5
Natty:
Report link

In case somebody has this same problem, as @Turo mentioned, the solution is analytic functions. Here's how I achieved my desired result.

SELECT MGR,ENAME,SAL 
FROM
(
   SELECT MGR,ENAME,SAL,
   MAX(SAL) OVER (PARTITION BY MGR) AS MaxSal
   FROM EMP
)
WHERE SAL=MaxSal
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Me too answer (2): same problem
  • User mentioned (1): @Turo
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Paul