0% found this document useful (0 votes)
20 views4 pages

Practice No 4 SQL Slides

oracle slides practice 04

Uploaded by

Irfan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Practice No 4 SQL Slides

oracle slides practice 04

Uploaded by

Irfan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICE NO 4 SQL SLIDES

 1. SELECT last_name,d.department_id,department_name
o FROM employees e,departments d
o WHERE e.department_id = d.department_id ;

 2. SELECT distinct e.job_id,d.location_id


o FROM employees e,departments d
o WHERE e.department_id = d.department_id and department_id = 80

 3. SELECT e.last_name,d.department_name,l.location_id,l.city
FROM employees e,departments d,locations l
WHERE e.department_id = d.department_id
and d.location_id = l.location_id
and e.commission_pct is not null;

 4. SELECT last_name,department_name
FROM employees e,departments d
where d.department_id = e.department_id
and last_name like '%a%'

 5. SELECT e.last_name,e.job_id,e.department_id,d.department_name
from employees e, departments d
where e.department_id = d.department_id and d.location_id =
1800;
 6. SELECT m.last_name employee ,m.employee_id "Emp#"
,w.last_name manager ,m.manager_id "Mgr#"
FROM employees w,employees m
where m.manager_id = w.employee_id
order by m.manager_id,m.employee_id

 7. SELECT w.last_name employee ,w.employee_id "Emp#"


,m.last_name manager ,w.manager_id "Mgr#"
FROM employees w,employees m
WHERE w.manager_id = m.employee_id (+)
order by w.employee_id

 8. SELECT w.department_id department,w.last_name employee ,


m.last_name
FROM employees w,employees m
WHERE w.manager_id = m.department_id
order by w.department_id

 9. SELECT e.last_name,e.job_id,d.department_name,e.salary
FROM employees e , departments d
WHERE e.department_id = d.department_id

 10. SELECT w.last_name employee ,w.hire_date "Emp Hired",


m.last_name manager,m.hire_date "Mgr Hired"
FROM employees w, employees m
WHERE w.manager_id = m.employee_id
and m.hire_date > w.hire_date
SLIDE NO 5 SQL PRACTICE
 1. TRUE

 2. FALSE

 3. TRUE

 4. SELECT MAX(salary) maximum ,


MIN(salary) minimum ,SUM(salary)
sum ROUND(AVG(salary),0) average
FROM employees

 5. SELECT job_id,MAX(salary) maximum,


MIN(salary) minimum ,SUM(salary)
sum,ROUND (AVG(salary),0) average
FROM employees
GROUP BY job_id
ORDER BY job_id

 6. SELECT job_id,count(*)
FROM employees
GROUP BY job_id
 7. SELECT count( distinct manager_id )
“Number of Managers”
FROM employees;

 8. SELECT MAX(salary)-MIN(salary) difference


FROM employees;

 9. SELECT manager_id, MIN(salary)


FROM employees
WHERE manager_id is not null
HAVING MIN(salary) > 6000
GROUP BY manager_id
ORDER BY MIN(salary) desc;

 10. SELECT
department_name,location_id,count(job_i),
Round(AVG(salary),2)
FROM employees e,departments d
WHERE d.department_id = e.department_id
GROUP By d.department_id,
Department_name,location_id
ORDER BY department_name

You might also like