新人报道,求解SQL
select e.empname,
e.empsal,
(select sal.salclass
from sal
where e.empsal between sal.minsal and sal.maxsal) as 级别,
(select count(*)
from emp
where emp.empsal between
(select sal.minsal
from sal
where sal.salclass =
(select sal.salclass
from sal
where e.empsal between sal.minsal and sal.maxsal))
and (select sal.maxsal
from sal
where sal.salclass =
(select sal.salclass
from sal
where e.empsal between sal.minsal and sal.maxsal))) as 人数,
(select avg(emp.empsal)
from emp
where emp.empsal between
(select sal.minsal
from sal
where sal.salclass =
(select sal.salclass
from sal
where e.empsal between sal.minsal and sal.maxsal))
and (select sal.maxsal
from sal
where sal.salclass =
(select sal.salclass
from sal
where e.empsal between sal.minsal and sal.maxsal))) as 平均
from emp e
where e.empid = 1