0

I Created two tables: Employee with salary and Departamento with the name of the department. I Would like to find out the max salaries for each department. The created tables are below:

CREATE TABLE Employee ( Id serial PRIMARY KEY, Name VARCHAR ( 50 ), Salary INT, DepartmentId INT );

CREATE TABLE Departamento ( Id serial PRIMARY KEY, Name VARCHAR ( 50 ) UNIQUE NOT NULL );

INSERT INTO Employee(Id, Name, Salary, DepartmentId) VALUES (1, 'Joe', 70000, 1), (2, 'Jim', 90000, 1), (3, 'Henry', 80000, 2), (4, 'Sam', 60000, 2), (5, 'Max', 90000, 1);

INSERT INTO Departamento(Id, Name) VALUES(1, 'IT'), (2, 'Sales')

I am expecting this output:

enter image description here

I've tried subqueries, distinct on but with no success. I Would appreciate any help :) Thanks!

0 Answers0