Below tables represent part of the schema for a company database. The company ha
ID: 3868213 • Letter: B
Question
Below tables represent part of the schema for a company database. The company has different branches in different cities. The city attribute shows the city that a branch is located in several branches can be located in the same city CREATE TABLE branch (Id INT PRIMARY KEY City VARCHAR(255) NOT NULL): CREATE TABLE employee (Id INT PRIMARY KEY, Fname VARCHAR(255) NOT NULL Lname VARCHAR(255) NOT NULL Birth date DATE NOT NULL Salary DOUBLE NOT NULL Branch id INT NOT NULL FOREIGN (branch_id) REFERENCES branch(id)) engine = innodb Write a query that returns the maximum salary for each city. So you should return two columns, 'city' and 'salary'. The salary should be the highest employee salary among all branches in the city. There should be one row per city.Explanation / Answer
Hi,
Below is the answer-
SELECT B.CITY,MAX(E.SALARY) FROM EMPLOYEE E
JOIN BRANCH B
ON E.BRANCH_ID=B.ID
GROUP BY B.CITY;
Regards,
Vinay Singh
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.