Assignment 6 DBMS

You might also like

You are on page 1of 3

QUESTION 1:-

Find out the ename, job,sal of the employees whose salaries are less than that of an employee whose
empno= 7876 from employees table
QUERY:-

select first_name||' '||last_name as ename,job_id,salary from HR.employees where salary<(select


salary from HR.employees where employee_id =200);
OUTPUT:-
ENAME JOB_ID SALARY
Diana Lorentz IT_PROG 4200
Alexander Khoo PU_CLERK 3100
Shelli Baida PU_CLERK 2900
Sigal Tobias PU_CLERK 2800
Guy Himuro PU_CLERK 2600
Karen Colmenares PU_CLERK 2500
Julia Nayer ST_CLERK 3200
Irene
ST_CLERK 2700
Mikkilineni
James Landry ST_CLERK 2400
Steven Markle ST_CLERK 2200
Laura Bissot ST_CLERK 3300
Mozhe Atkinson ST_CLERK 2800
James Marlow ST_CLERK 2500
TJ Olson ST_CLERK 2100

QUESTION 2:-

Display the name of the employees/employee who gets the second highest salary. (use employee
table).
QUERY:-
SELECT * FROM HR.EMPLOYEES WHERE employee_id IN (SELECT employee_id FROM HR.EMPLOYEES
WHERE salary = (SELECT MAX(salary) FROM HR.EMPLOYEES WHERE salary < (SELECT MAX(salary)
FROM HR.EMPLOYEES)))
OUTPUT:-
FIRST_NAM HIRE_DAT
EMPLOYEE_ID LAST_NAME EMAIL PHONE_NUMBER JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
E E
21-SEP-
101 Neena Kochhar NKOCHHAR 515.123.4568 AD_VP 17000 - 100 90
05
13-JAN-
102 Lex De Haan LDEHAAN 515.123.4569 AD_VP 17000 - 100 90
01
QUESTION 3:-

Display firstname, lastname, salary of those sales representatives whoearns a higher salary than the
minimum salary a sales manager receives
QUERY:-

select first_name,last_name,salary from hr.employees where salary > (select min(salary)from


hr.employees where job_id ='SA_MAN');
OUTPUT:-
FIRST_NAM
LAST_NAME SALARY
E
Steven King 24000
Neena Kochhar 17000
Lex De Haan 17000
Nancy Greenberg 12008
Den Raphaely 11000
John Russell 14000
Karen Partners 13500
Alberto Errazuriz 12000
Gerald Cambrault 11000
Lisa Ozer 11500
Ellen Abel 11000
Michael Hartstein 13000
Shelley Higgins 12008

QUESTION 4:-

List the employees that makes the same salary as other employee whichhas same job as empno=7521.
QUERY:-

select * from HR.employees where salary = (select salary from hr.employees where employee_id=150);
OUTPUT:-
FIRST_NAM HIRE_DAT COMMISSION_PC
EMPLOYEE_ID LAST_NAME EMAIL PHONE_NUMBER JOB_ID SALARY MANAGER_ID DEPARTMENT_ID
E E T
PTUCKE 30-JAN-
150 Peter Tucker 011.44.1344.129268 SA_REP 10000 .3 145 80
R 05
30-JAN-
156 Janette King JKING 011.44.1345.429268 SA_REP 10000 .35 146 80
04
23-MAR-
169 Harrison Bloom HBLOOM 011.44.1343.829268 SA_REP 10000 .2 148 80
06
07-JUN-
204 Hermann Baer HBAER 515.123.8888 PR_REP 10000 - 101 70
02
QUESTION 5:-

Display the employee detail with salary less than those whose job is ‘ST_MAN’.
QUERY:-

select * from HR.employees where salary < (select min(salary) from HR.employees where job_id
='ST_MAN');
OUTPUT:-
EMPLOYEE_I FIRST_NAM PHONE_NUMBE HIRE_DAT SALAR COMMISSION_PC MANAGER_I DEPARTMENT_I
LAST_NAME EMAIL JOB_ID
D E R E Y T D D
590.423.456 25-JUN-
105 David Austin DAUSTIN IT_PROG 4800 - 103 60
9 05
VPATABA 590.423.456 05-FEB-
106 Valli Pataballa IT_PROG 4800 - 103 60
L 0 06
DLORENT 590.423.556 07-FEB-
107 Diana Lorentz IT_PROG 4200 - 103 60
Z 7 07
515.127.456 18-MAY- PU_CLER
115 Alexander Khoo AKHOO 3100 - 114 30
2 03 K
515.127.456 24-DEC- PU_CLER
116 Shelli Baida SBAIDA 2900 - 114 30
3 05 K
515.127.456 24-JUL- PU_CLER
117 Sigal Tobias STOBIAS 2800 - 114 30
4 05 K
515.127.456 15-NOV- PU_CLER
118 Guy Himuro GHIMURO 2600 - 114 30
5 06 K
KCOLMEN 515.127.456 10-AUG- PU_CLER
119 Karen Colmenares 2500 - 114 30
A 6 07 K
650.124.121 16-JUL- ST_CLER
125 Julia Nayer JNAYER 3200 - 120 50
4 05 K
Mikkilinen IMIKKIL 650.124.122 28-SEP- ST_CLER
126 Irene 2700 - 120 50
i I 4 06 K
650.124.133 14-JAN- ST_CLER
127 James Landry JLANDRY 2400 - 120 50
4 07 K
650.124.143 08-MAR- ST_CLER
128 Steven Markle SMARKLE 2200 - 120 50
4 08 K
650.124.523 20-AUG- ST_CLER
129 Laura Bissot LBISSOT 3300 - 121 50
4 05 K
MATKINS 650.124.623 30-OCT- ST_CLER
130 Mozhe Atkinson 2800 - 121 50
O 4 05 K

QUESTION 6:-

Finds the employee whose salary is the same as the minimum salary of the employees in the
department.
QUERY:-

select * from HR.employees where salary =(select min(salary) from HR.employees);


OUTPUT:-
LAST_NAM PHONE_NUMBE
EMPLOYEE_ID FIRST_NAME EMAIL HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
E R
650.124.823 ST_CLER
132 TJ Olson TJOLSON 10-APR-07 2100 - 121 50
4 K

You might also like