You are on page 1of 3

select * from employee

select * from department


select * from salary

1.
select [name] from employee,salary
where employee.empno=salary.empno and pay>8000

2.
select employee.[name] from employee,department
where employee.deptid=department.deptid
and dt_join='11-oct-1991'

3.
select employee.[name] from employee,department
where employee.deptid=department.deptid
and department.[name]<>'Consultancy'

4.
select [name] from employee,salary
where employee.empno=salary.empno and pay<=5000

5.
select [name] from employee,salary
where employee.empno=salary.empno and pay>=8000

6.
select count(*) as num_rows from employee

7.
select count(empno) no_emp_d1 from employee where deptid='d1'

8.
select count(employee.empno) from employee,salary
where employee.empno=salary.empno and pay<6000 and deptid='d1'

9.
select count(distinct deptid) from employee

10.
select sum(basic) as tot_basic from salary
11.
select sum(basic)
from salary
where empno in
(select empno
from employee
where deptid='d1')
12.

Using Join
select sum(basic) from
employee e, department d, salary s
where e.deptid=d.deptid and e.empno=s.empno
and e.deptid='d1' and not pay < 6000

Using Sub Query


select sum(basic) from salary
where not pay < 6000 and empno in
(select empno from employee
where deptid='d1')

13.
select sum(pay)
from salary
where empno in
(select empno
from employee
where deptid='d1')

14.
Using joins
select sum(basic) from
employee e, department d, salary s
where e.deptid=d.deptid and e.empno=s.empno
and e.deptid='d1' and basic between 6000 and 8000

Using Sub Query


select sum(basic) from salary
where basic between 6000 and 8000 and empno in
(select empno from employee
where deptid='d1')
15.
select avg(hra) avg_hra from salary

You might also like