sql查询语句 给出4张表,找出雇员最多的公司

2024-11-27 12:03:31
推荐回答(4个)
回答1:

mysql
select company_name, count(employee_name) employee_count
from works
group by company_name
order by count(employee_name) desc limit 1,1

sql server
select top 1 company_name, count(employee_name) employee_count
from works
group by company_name
order by count(employee_name) desc

回答2:

select max(employee_count) from (
select count(employee_name) employee_count from employee e,works w,company c where e.employee_name=w.employee_name and w.company_name=c.company_name group by company_name ) t

回答3:

--把雇员最多的公司排序
select
*
from company as a
order by (select count(1) from works where company_name=a.company_name) desc

回答4:

问题好像不太明朗