2021-03-02

select a.dept_name,a.`name`,a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

SELECT @@GLOBAL.sql_mode;

 set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

  select max(id) as id,name from tbl_employee group by name;

explain Select  distinct st.name from tbl_middle_student st left join tbl_middle_score sc on  st.id = sc.stu_id where sc.score = 100 order by st.name;

select name from tbl_middle_student where id in( select distinct(stu_id) from tbl_middle_score sc where sc.score = 100);

select name from tbl_middle_student st where EXISTS (select distinct(stu_id) as id from tbl_middle_score sc where sc.score = 100 and st.id = sc.stu_id);

select * from tbl_employee;

select * from tbl_department;

select a.dept_name,a.name, a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`,a.dept_id, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

select a.dept_name,a.`name`, max(a.salary) from (select info.dept_id,info.dept_name,emp.name,emp.salary from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id

)a group by dept_id;

SELECT @@GLOBAL.sql_mode;

 set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

select dept_id,max(salary) from tbl_employee emp group by emp.dept_id;

select emp.dept_id,max(salary) as '薪资' from tbl_employee emp left join tbl_department depart on depart.dept_id = 

emp.dept_id

 group by emp.dept_id;


 select a.dept_name,emp.name, m.salary from (select emp.dept_id,max(salary) as 'salary' from tbl_employee emp left join tbl_department depart on depart.dept_id = 

emp.dept_id

 group by emp.dept_id) m right join tbl_department a on  a.dept_id = m.dept_id

left join tbl_employee emp on emp.salary = m.salary;


 select a.dept_name,emp.name, m.salary from (select info.dept_id,info.dept_name from tbl_department info)a


 select info.dept_id,info.dept_name,emp.name from tbl_department info,tbl_employee emp where info.dept_id = emp.dept_id



 select emp.name,max(salary) from tbl_employee emp left join tbl_department depart on depart.dept_id = 

emp.dept_id

 group by emp.dept_id;



 select emp.name,depart.dept_name,emp.dept_id, max(salary) from tbl_employee emp left join tbl_department depart on depart.dept_id = 

emp.dept_id

 group by emp.dept_id;


你可能感兴趣的:(2021-03-02)