使用以下代码我得到最大值
select
max(e.maxNum)
from (select
companyno as cn,
count(employeeNo) as maxNum
from works
group by companyNo) e;
但我也需要像“companyno,e.maxNum”这样的“companyNo”
我试过
select
e.cn,
max(e.maxNum)
from (select
companyno as cn,
count(employeeNo) as maxNum
from works
group by companyNo) e;
但我收到错误
如何解决这个问题?
表格式
works(employeeNo, companyNo, salary)
company(companyNo, companyName, city)
答案 0 :(得分:2)
select
max(CompanyNo) keep (dense_rank first order by count(employeeNo) desc) as cn,
max(count(employeeNo)) maxNum
from Works
group by CompanyNo