KPax
asked on
Oracle MAX function
-- OK this works fine if I want to extract maxmum value from
-- group and by taht I mean that there is data such as departments and tehre are
-- veriuos salaries in those departments so MAX extracts the biggest one from each group
-- in this case DEPARTMENT_ID and that's it
-- But what if I want to find single individual(s) with highest sallary?
-- and to dispaly his/her/their name and ID?
-- WITHOUT using JOIN just with selects or nested selects?
-- With following query MAX function displays ALL employess wityh their salaries
-- group and by taht I mean that there is data such as departments and tehre are
-- veriuos salaries in those departments so MAX extracts the biggest one from each group
-- in this case DEPARTMENT_ID and that's it
SELECT DEPARTMENT_ID, MAX(SALARY)
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID;
-- But what if I want to find single individual(s) with highest sallary?
-- and to dispaly his/her/their name and ID?
-- WITHOUT using JOIN just with selects or nested selects?
-- With following query MAX function displays ALL employess wityh their salaries
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, MAX(SALARY)
FROM EMPLOYEES
GROUP BY EMPLOYEE_ID, FIRST_NAME, LAST_NAME;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Although I am not quite sure what was this supposed to do
Open in new window
this
Open in new window
makes perfect sense to me and it works!