mysql>createtableifnotexists Employee (-> Id intnotnullprimarykey,-> Name VARCHAR(50)notnull,-> Salary intnotnull,-> DepartmentId intnotnull->);
mysql>insertinto Employee values(1,'Joe',70000,1);
mysql>insertinto Employee values(2,'Henry',80000,2);
mysql>insertinto Employee values(3,'Sam',60000,2);
mysql>insertinto Employee values(4,'Max',90000,1);
mysql>select*from Employee;+----+-------+--------+--------------+| Id | Name | Salary | DepartmentId |+----+-------+--------+--------------+|1| Joe |70000|1||2| Henry |80000|2||3| Sam |60000|2||4| Max |90000|1|+----+-------+--------+--------------+
mysql>createtableifnotexists Department (-> Id intnotnullprimarykey,-> Name VARCHAR(50)notnull->);
mysql>insertinto Department values(1,'IT');
mysql>insertinto Department values(2,'Sales');
mysql>select*from Department;+----+-------+| Id | Name |+----+-------+|1| IT ||2| Sales |+----+-------+
mysql>select E.Name as Name,E.Salary,D.Name as department
->from Employee E join Department D on E.DepartmentId=D.Id
->where(E.Salary,E.DepartmentId)in(selectmax(Salary),DepartmentId from Employee groupby DepartmentId);+-------+--------+------------+| Name | Salary | department |+-------+--------+------------+| Henry |80000| Sales || Max |90000| IT |+-------+--------+------------+
task7mysql> create table if not exists Employee ( -> Id int not null primary key, -> Name VARCHAR(50) not null, -> Salary int not null, -> DepartmentId int not null ...