Empm Deptm: Select From Select From
Empm Deptm: Select From Select From
--2) List all the employees who have a sal between 1000
and 2000.
select ename from empm
where sal between 1000 and 2000
select *
from empm
where mgr is not null
--8) Display name and total remuneration for all
employees.
select ename,empno,
case when sal>1500 then 'just salary'
when sal=1500 then 'on target'
when sal<1500 then 'below target'
end
as "position"
from empm
select datename(dw,hiredate)
from empm
select min(sal)
from empm
--19) List the minimum and maximum sal for each job
type.
select d.dname
from deptm d
inner join empm e
on d.deptno=e.empno
select isnumeric(empno)
from empm
select min(sal)
from empm
except select min(sal) from empm
where sal<200
group by mgr
select e.ename,d.dname
from empm e,deptm d
order by d.dname
select e.ename,d.dname,d.deptno
from empm e,deptm d
select e.ename,d.loc,d.deptno
from empm e,deptm d
where e.sal>1500
select e.ename,e.job,e.sal,g.grade,d.dname
from empm e,deptm d,salgradem g
--except select e.ename,e.job,e.sal,g.grade,d.dname
-- from empm e,deptm d,salgradem g
-- where e.job='clerk'
where e.job not in ('clerk')
order by e.sal desc
select ename,empno
from empm
where sal*12>36000 or job='clerk'
select distinct(d.dname)
from deptm d left outer join empm e
on e.deptno=d.deptno
--35) List all EMP by name and number along with
their manager’s name and number.
select e.ename
from emp e
where e.mgr is null
--37) Find the job that was filled in the first half
of 1983, and the
--same job that was filled during the same period in
1984.
select deptno,min(hiredate)
from empm
group by deptno
select ename,sal
from empm
where sal in (select max(sal) from empm group by
deptno)
select deptno,sal
from empm
where sal in (select min(sal) from empm group by
deptno)
select ename,sal
from empm
where sal>(select min(sal) from empm where deptno=30)
select ename,job,hiredate
from empm where sal>(select max(e.sal) from empm
e,deptm d where d.dname='sales')
select e.ename,d.dname
from empm e,deptm d
where d.dname not in (select dname from deptm)