You are on page 1of 124

Ans 1.

SQL> select last_name || ', '||job_id "Details" from employees;

Details
------------------------------------King, AD_PRES
Kochhar, AD_VP
De Haan, AD_VP
Hunold, IT_PROG
Ernst, IT_PROG
Austin, IT_PROG
Pataballa, IT_PROG
Lorentz, IT_PROG
Greenberg, FI_MGR
Faviet, FI_ACCOUNT
Chen, FI_ACCOUNT

Details
------------------------------------Sciarra, FI_ACCOUNT
Urman, FI_ACCOUNT
Popp, FI_ACCOUNT
Raphaely, PU_MAN
Khoo, PU_CLERK
Baida, PU_CLERK

Tobias, PU_CLERK
Himuro, PU_CLERK
Colmenares, PU_CLERK
Weiss, ST_MAN
Fripp, ST_MAN

Details
------------------------------------Kaufling, ST_MAN
Vollman, ST_MAN
Mourgos, ST_MAN
Nayer, ST_CLERK
Mikkilineni, ST_CLERK
Landry, ST_CLERK
Markle, ST_CLERK
Bissot, ST_CLERK
Atkinson, ST_CLERK
Marlow, ST_CLERK
Olson, ST_CLERK

Details
------------------------------------Mallin, ST_CLERK
Rogers, ST_CLERK
Gee, ST_CLERK

Philtanker, ST_CLERK
Ladwig, ST_CLERK
Stiles, ST_CLERK
Seo, ST_CLERK
Patel, ST_CLERK
Rajs, ST_CLERK
Davies, ST_CLERK
Matos, ST_CLERK

Details
------------------------------------Vargas, ST_CLERK
Russell, SA_MAN
Partners, SA_MAN
Errazuriz, SA_MAN
Cambrault, SA_MAN
Zlotkey, SA_MAN
Tucker, SA_REP
Bernstein, SA_REP
Hall, SA_REP
Olsen, SA_REP
Cambrault, SA_REP

Details
-------------------------------------

Tuvault, SA_REP
King, SA_REP
Sully, SA_REP
McEwen, SA_REP
Smith, SA_REP
Doran, SA_REP
Sewall, SA_REP
Vishney, SA_REP
Greene, SA_REP
Marvins, SA_REP
Lee, SA_REP

Details
------------------------------------Ande, SA_REP
Banda, SA_REP
Ozer, SA_REP
Bloom, SA_REP
Fox, SA_REP
Smith, SA_REP
Bates, SA_REP
Kumar, SA_REP
Abel, SA_REP
Hutton, SA_REP
Taylor, SA_REP

Details
------------------------------------Livingston, SA_REP
Grant, SA_REP
Johnson, SA_REP
Taylor, SH_CLERK
Fleaur, SH_CLERK
Sullivan, SH_CLERK
Geoni, SH_CLERK
Sarchand, SH_CLERK
Bull, SH_CLERK
Dellinger, SH_CLERK
Cabrio, SH_CLERK

Details
------------------------------------Chung, SH_CLERK
Dilly, SH_CLERK
Gates, SH_CLERK
Perkins, SH_CLERK
Bell, SH_CLERK
Everett, SH_CLERK
McCain, SH_CLERK
Jones, SH_CLERK

Walsh, SH_CLERK
Feeney, SH_CLERK
OConnell, SH_CLERK

Details
------------------------------------Grant, SH_CLERK
Whalen, AD_ASST
Hartstein, MK_MAN
Fay, MK_REP
Mavris, HR_REP
Baer, PR_REP
Higgins, AC_MGR
Gietz, AC_ACCOUNT

107 rows selected.

Ans 2.
SQL> select last_name,salary from employees where salary > 12000;

LAST_NAME

SALARY

------------------------- ---------King

24000

Kochhar

17000

De Haan

17000

Russell

14000

Partners

13500

Hartstein

13000

6 rows selected.

Ans 3.
SQL> select last_name,salary from employees where salary not between 5000 and 12
000;

LAST_NAME

SALARY

------------------------- ---------King

24000

Kochhar

17000

De Haan

17000

Austin

4800

Pataballa

4800

Lorentz

4200

Khoo

3100

Baida

2900

Tobias

2800

Himuro
Colmenares

2600
2500

LAST_NAME

SALARY

------------------------- ---------Nayer
Mikkilineni

3200
2700

Landry

2400

Markle

2200

Bissot

3300

Atkinson

2800

Marlow

2500

Olson

2100

Mallin

3300

Rogers

2900

Gee

LAST_NAME

2400

SALARY

------------------------- ---------Philtanker
Ladwig

2200
3600

Stiles

3200

Seo

2700

Patel

2500

Rajs

3500

Davies

3100

Matos

2600

Vargas

2500

Russell
Partners

LAST_NAME

14000
13500

SALARY

------------------------- ---------Taylor

3200

Fleaur

3100

Sullivan

2500

Geoni

2800

Sarchand
Bull
Dellinger

4200
4100
3400

Cabrio

3000

Chung

3800

Dilly
Gates

LAST_NAME

3600
2900

SALARY

------------------------- ---------Perkins
Bell
Everett
McCain

2500
4000
3900
3200

Jones

2800

Walsh

3100

Feeney

3000

OConnell

2600

Grant

2600

Whalen

4400

Hartstein

13000

55 rows selected.

Ans 4.
SQL> select last_name, job_id,hire_date from employees where last_name in('Mtos'
,'Taylor') order by hire_date;

LAST_NAME

JOB_ID

HIRE_DATE

------------------------- ---------- --------Taylor

SH_CLERK 24-JAN-98

Taylor

SA_REP

24-MAR-98

Ans 5.
SQL> select last_name,department_id from employees where department_id in (20,50
) order by first_name;

LAST_NAME

DEPARTMENT_ID

------------------------- ------------Fripp

50

Walsh
Bull

50
50

Cabrio

50

Everett

50

Davies

50

OConnell

50

Grant

50

Geoni

50

Philtanker

50

Mikkilineni

50

LAST_NAME

DEPARTMENT_ID

------------------------- ------------Marlow

50

Landry

50

Mallin

50

Fleaur

50

Dilly

50

Seo

50

Patel

50

Nayer

50

Dellinger

50

Chung

50

Mourgos

50

LAST_NAME

DEPARTMENT_ID

------------------------- ------------Feeney

50

Gee

50

Bissot

50

Sullivan

50

Weiss

50

Hartstein
Rogers

20
50

Atkinson

50

Sarchand

50

Fay
Kaufling

LAST_NAME

20
50

DEPARTMENT_ID

------------------------- ------------Vargas

50

Perkins

50

Matos

50

Ladwig

50

McCain

50

Bell
Vollman
Stiles
Markle

50
50
50
50

Olson

50

Gates

50

LAST_NAME

DEPARTMENT_ID

------------------------- ------------Rajs

50

Jones

50

Taylor

50

47 rows selected.

Ans 6.
SQL> select last_name "Employee",salary "Monthly Salary" from employees where sa
lary between 5000 and 12000 and department_id in (20,50);

Employee

Monthly Salary

------------------------- -------------Weiss
Fripp

8000
8200

Kaufling

7900

Vollman

6500

Mourgos

5800

Fay

6 rows selected.

6000

Ans 7.
SQL> select last_name,hire_date from employees where to_char(hire_date,'yyyy')=1
994;

LAST_NAME

HIRE_DATE

------------------------- --------Greenberg
Faviet
Raphaely
Mavris
Baer
Higgins
Gietz

17-AUG-94
16-AUG-94
07-DEC-94
07-JUN-94
07-JUN-94
07-JUN-94
07-JUN-94

7 rows selected.

Ans 8.
SQL> select e.last_name,j.job_title from employees e,jobs j where e.job_id=j.job
_id and e.manager_id is null;

LAST_NAME

JOB_TITLE

------------------------- ----------------------------------King

President

Ans 9.
SQL> select last_name,salary from employees where salary > &salary;
Enter value for salary: 5000
old 1: select last_name,salary from employees where salary > &salary
new 1: select last_name,salary from employees where salary > 5000

LAST_NAME

SALARY

------------------------- ---------King

24000

Kochhar

17000

De Haan

17000

Hunold

9000

Ernst
Greenberg

6000
12000

Faviet

9000

Chen

8200

Sciarra

7700

Urman
Popp

LAST_NAME

7800
6900

SALARY

------------------------- ---------Raphaely
Weiss
Fripp

11000
8000
8200

Kaufling

7900

Vollman

6500

Mourgos

5800

Russell

14000

Partners

13500

Errazuriz

12000

Cambrault
Zlotkey

LAST_NAME

11000
10500

SALARY

------------------------- ---------Tucker
Bernstein
Hall
Olsen
Cambrault
Tuvault

10000
9500
9000
8000
7500
7000

King

10000

Sully

9500

McEwen

9000

Smith

8000

Doran

7500

LAST_NAME

SALARY

------------------------- ----------

Sewall

7000

Vishney

10500

Greene

9500

Marvins

7200

Lee

6800

Ande

6400

Banda

6200

Ozer
Bloom
Fox
Smith

LAST_NAME

11500
10000
9600
7400

SALARY

------------------------- ---------Bates
Kumar
Abel
Hutton
Taylor
Livingston
Grant

7300
6100
11000
8800
8600
8400
7000

Johnson

6200

Hartstein

13000

Fay
Mavris

6000
6500

LAST_NAME

SALARY

------------------------- ---------Baer

10000

Higgins

12000

Gietz

8300

58 rows selected.

Ans 10.
SQL> select e.employee_id,e.last_name,e.salary,d.department_name from employees
e,departments d where d.manager_id=e.manager_id and e.manager_id=&manager_id;
Enter value for manager_id: 110

Ans 11. SQL> select last_name from employees where first_name like '__a%';

LAST_NAME
------------------------Fleaur
Fripp
Johnson
Lorentz
Vishney
Vollman

Walsh

7 rows selected.

Ans 12.
SQL> select last_name from employees where last_name like '%a%e%';

LAST_NAME
------------------------Baer
Bates
Colmenares
Davies
Faviet
Gates
Hartstein
Markle
Nayer
Partners
Patel

LAST_NAME
-------------------------

Philtanker
Raphaely
Whalen

14 rows selected.
Ans 13.
SQL> select e.last_name,j.job_title,e.salary from employees e,jobs j where j.job
_title in ('Sales Representative','Stock Clerk') and salary not in (2500,3500,70
00);

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------King

Sales Representative

24000

Kochhar

Sales Representative

17000

De Haan

Sales Representative

17000

Hunold

Sales Representative

9000

Ernst

Sales Representative

6000

Austin

Sales Representative

4800

Pataballa

Sales Representative

4800

Lorentz

Sales Representative

4200

Greenberg

Sales Representative

12000

Faviet

Sales Representative

9000

Chen

Sales Representative

8200

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Sciarra


Urman
Popp
Raphaely

Sales Representative
Sales Representative
Sales Representative
Sales Representative

7700
7800
6900
11000

Khoo

Sales Representative

3100

Baida

Sales Representative

2900

Tobias

Sales Representative

2800

Himuro
Weiss
Fripp
Kaufling

LAST_NAME

Sales Representative
Sales Representative
Sales Representative
Sales Representative

JOB_TITLE

2600
8000
8200
7900

SALARY

------------------------- ----------------------------------- ---------Vollman

Sales Representative

6500

Mourgos

Sales Representative

5800

Nayer
Mikkilineni

Sales Representative
Sales Representative

3200
2700

Landry

Sales Representative

2400

Markle

Sales Representative

2200

Bissot
Atkinson

Sales Representative
Sales Representative

3300
2800

Olson

Sales Representative

2100

Mallin

Sales Representative

3300

Rogers

LAST_NAME

Sales Representative

JOB_TITLE

2900

SALARY

------------------------- ----------------------------------- ---------Gee


Philtanker
Ladwig

Sales Representative
Sales Representative
Sales Representative

2400
2200
3600

Stiles

Sales Representative

3200

Seo

Sales Representative

2700

Davies

Sales Representative

3100

Matos

Sales Representative

2600

Russell

Sales Representative

14000

Partners

Sales Representative

13500

Errazuriz

Sales Representative

12000

Cambrault

LAST_NAME

Sales Representative

JOB_TITLE

11000

SALARY

------------------------- ----------------------------------- ---------Zlotkey

Sales Representative

10500

Tucker

Sales Representative

10000

Bernstein
Hall
Olsen
Cambrault
King

Sales Representative
Sales Representative
Sales Representative
Sales Representative
Sales Representative

9500
9000
8000
7500
10000

Sully
McEwen

Sales Representative
Sales Representative

9500
9000

Smith

Sales Representative

8000

Doran

Sales Representative

7500

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Vishney

Sales Representative

10500

Greene

Sales Representative

9500

Marvins

Sales Representative

7200

Lee

Sales Representative

6800

Ande

Sales Representative

6400

Banda

Sales Representative

6200

Ozer
Bloom
Fox

Sales Representative
Sales Representative
Sales Representative

11500
10000
9600

Smith

Sales Representative

7400

Bates

Sales Representative

7300

JOB_TITLE

SALARY

LAST_NAME

------------------------- ----------------------------------- ---------Kumar


Abel
Hutton
Taylor

Sales Representative
Sales Representative
Sales Representative
Sales Representative

6100
11000
8800
8600

Livingston

Sales Representative

8400

Johnson

Sales Representative

6200

Taylor

Sales Representative

3200

Fleaur

Sales Representative

3100

Geoni

Sales Representative

2800

Sarchand
Bull

LAST_NAME

Sales Representative
Sales Representative

JOB_TITLE

4200
4100

SALARY

------------------------- ----------------------------------- ---------Dellinger

Sales Representative

3400

Cabrio

Sales Representative

3000

Chung

Sales Representative

3800

Dilly
Gates
Bell
Everett
McCain

Sales Representative
Sales Representative
Sales Representative
Sales Representative
Sales Representative

3600
2900
4000
3900
3200

Jones

Sales Representative

2800

Walsh

Sales Representative

3100

Feeney

Sales Representative

3000

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------OConnell

Sales Representative

2600

Grant

Sales Representative

2600

Whalen

Sales Representative

4400

Hartstein

Sales Representative

13000

Fay
Mavris
Baer
Higgins

Sales Representative
Sales Representative
Sales Representative

Sales Representative

King

Stock Clerk

LAST_NAME

6500
10000

Sales Representative

Gietz

Kochhar

6000

Stock Clerk

JOB_TITLE

12000
8300
24000
17000

SALARY

------------------------- ----------------------------------- ---------De Haan

Stock Clerk

17000

Hunold

Stock Clerk

9000

Ernst

Stock Clerk

6000

Austin

Stock Clerk

4800

Pataballa

Stock Clerk

4800

Lorentz

Stock Clerk

4200

Greenberg

Stock Clerk

12000

Faviet

Stock Clerk

9000

Chen

Stock Clerk

8200

Sciarra

Stock Clerk

7700

Urman

Stock Clerk

7800

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Popp


Raphaely

Stock Clerk
Stock Clerk

6900
11000

Khoo

Stock Clerk

3100

Baida

Stock Clerk

2900

Tobias

Stock Clerk

2800

Himuro
Weiss
Fripp
Kaufling

Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk

2600
8000
8200
7900

Vollman

Stock Clerk

6500

Mourgos

Stock Clerk

5800

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Nayer


Mikkilineni

Stock Clerk
Stock Clerk

3200
2700

Landry

Stock Clerk

2400

Markle

Stock Clerk

2200

Bissot
Atkinson

Stock Clerk
Stock Clerk

3300
2800

Olson

Stock Clerk

2100

Mallin

Stock Clerk

3300

Rogers

Stock Clerk

2900

Gee
Philtanker

LAST_NAME

Stock Clerk
Stock Clerk

JOB_TITLE

2400
2200

SALARY

------------------------- ----------------------------------- ---------Ladwig

Stock Clerk

3600

Stiles

Stock Clerk

3200

Seo

Stock Clerk

2700

Davies

Stock Clerk

3100

Matos

Stock Clerk

2600

Russell

Stock Clerk

14000

Partners

Stock Clerk

13500

Errazuriz

Stock Clerk

12000

Cambrault

Stock Clerk

11000

Zlotkey

Stock Clerk

10500

Tucker

Stock Clerk

10000

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Bernstein


Hall
Olsen
Cambrault

Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk

9500
9000
8000
7500

King

Stock Clerk

10000

Sully

Stock Clerk

9500

McEwen

Stock Clerk

9000

Smith

Stock Clerk

8000

Doran

Stock Clerk

7500

Vishney

Stock Clerk

10500

Greene

Stock Clerk

9500

LAST_NAME

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Marvins


Lee

Stock Clerk
Stock Clerk

7200
6800

Ande

Stock Clerk

6400

Banda

Stock Clerk

6200

Ozer
Bloom
Fox

Stock Clerk
Stock Clerk
Stock Clerk

11500
10000
9600

Smith

Stock Clerk

7400

Bates

Stock Clerk

7300

Kumar
Abel

LAST_NAME

Stock Clerk
Stock Clerk

JOB_TITLE

6100
11000

SALARY

------------------------- ----------------------------------- ---------Hutton


Taylor
Livingston

Stock Clerk
Stock Clerk
Stock Clerk

8800
8600
8400

Johnson

Stock Clerk

6200

Taylor

Stock Clerk

3200

Fleaur

Stock Clerk

3100

Geoni

Stock Clerk

2800

Sarchand
Bull
Dellinger
Cabrio

LAST_NAME

Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk

4200
4100
3400
3000

JOB_TITLE

SALARY

------------------------- ----------------------------------- ---------Chung


Dilly
Gates
Bell
Everett
McCain

Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk
Stock Clerk

3800
3600
2900
4000
3900
3200

Jones

Stock Clerk

2800

Walsh

Stock Clerk

3100

Feeney

Stock Clerk

3000

OConnell
Grant

LAST_NAME

Stock Clerk
Stock Clerk

JOB_TITLE

2600
2600

SALARY

------------------------- ----------------------------------- ----------

Whalen

Stock Clerk

4400

Hartstein

Stock Clerk

13000

Fay

Stock Clerk

Mavris
Baer

Stock Clerk

6500

Stock Clerk

Higgins
Gietz

6000

10000

Stock Clerk

12000

Stock Clerk

8300

194 rows selected.

Ans 14.
SQL> select sysdate "Date" from dual;

Date
--------14-AUG-12

Ans 15. 2
SQL> select employee_id ,last_name,salary,round(salary+salary*.15,0) from emplo
yees;

EMPLOYEE_ID LAST_NAME

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------100 King


101 Kochhar

24000
17000

27600
19550

102 De Haan

17000

103 Hunold

9000

19550
10350

104 Ernst

6000

6900

105 Austin

4800

5520

106 Pataballa

4800

5520

107 Lorentz

4200

4830

108 Greenberg

12000

13800

109 Faviet

9000

10350

110 Chen

8200

9430

EMPLOYEE_ID LAST_NAME

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------111 Sciarra


112 Urman
113 Popp
114 Raphaely

7700
7800
6900
11000

8855
8970
7935
12650

115 Khoo

3100

3565

116 Baida

2900

3335

117 Tobias

2800

3220

118 Himuro
119 Colmenares
120 Weiss
121 Fripp

EMPLOYEE_ID LAST_NAME

2600
2500
8000
8200

2990
2875
9200
9430

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------122 Kaufling

7900

9085

123 Vollman

6500

7475

124 Mourgos

5800

6670

125 Nayer
126 Mikkilineni

3200
2700

3680
3105

127 Landry

2400

2760

128 Markle

2200

2530

129 Bissot

3300

3795

130 Atkinson

2800

3220

131 Marlow

2500

2875

132 Olson

2100

EMPLOYEE_ID LAST_NAME

2415

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------133 Mallin

3300

3795

134 Rogers

2900

3335

135 Gee
136 Philtanker
137 Ladwig

2400
2200
3600

2760
2530
4140

138 Stiles

3200

3680

139 Seo

2700

3105

140 Patel

2500

2875

141 Rajs

3500

4025

142 Davies

3100

3565

143 Matos

2600

EMPLOYEE_ID LAST_NAME

2990

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------144 Vargas

2500

2875

145 Russell

14000

16100

146 Partners

13500

15525

147 Errazuriz

12000

13800

148 Cambrault

11000

12650

149 Zlotkey

10500

12075

150 Tucker

10000

11500

9500

10925

151 Bernstein
152 Hall
153 Olsen
154 Cambrault

9000
8000
7500

EMPLOYEE_ID LAST_NAME

10350
9200
8625

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------155 Tuvault

7000

156 King

10000

157 Sully

9500

158 McEwen

9000

8050
11500
10925
10350

159 Smith

8000

9200

160 Doran

7500

8625

161 Sewall

7000

8050

162 Vishney

10500

12075

163 Greene

9500

10925

164 Marvins

7200

8280

165 Lee

6800

EMPLOYEE_ID LAST_NAME

7820

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------166 Ande

6400

7360

167 Banda

6200

7130

11500

13225

168 Ozer
169 Bloom
170 Fox

10000
9600

11500
11040

171 Smith

7400

8510

172 Bates

7300

8395

173 Kumar
174 Abel
175 Hutton
176 Taylor

6100

7015

11000

12650

8800

10120

8600

EMPLOYEE_ID LAST_NAME

9890

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------177 Livingston


178 Grant
179 Johnson
180 Taylor

8400
7000
6200
3200

9660
8050
7130
3680

181 Fleaur

3100

3565

182 Sullivan

2500

2875

183 Geoni

2800

3220

184 Sarchand
185 Bull
186 Dellinger
187 Cabrio

4200
4100
3400
3000

EMPLOYEE_ID LAST_NAME

4830
4715
3910
3450

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------188 Chung


189 Dilly

3800
3600

4370
4140

190 Gates

2900

3335

191 Perkins

2500

2875

192 Bell
193 Everett
194 McCain

4000
3900
3200

4600
4485
3680

195 Jones

2800

3220

196 Walsh

3100

3565

197 Feeney

3000

3450

198 OConnell

2600

EMPLOYEE_ID LAST_NAME

2990

SALARY ROUND(SALARY+SALARY*.15,0)

----------- ------------------------- ---------- -------------------------199 Grant

2600

2990

200 Whalen

4400

5060

201 Hartstein

13000

14950

202 Fay

6000

203 Mavris
204 Baer

6900

6500

7475

10000

11500

205 Higgins

12000

206 Gietz

8300

13800
9545

107 rows selected.

Ans 16. SP2-0734: unknown command beginning "e first_na..." - rest of line ignored.
SQL> select initcap(last_name) "Last Name", length(last_name) "Length" from empl
oyees where first_name like 'J%' or last_name like 'A%' or last_name like 'M%' o
rder by last_name;

Last Name

Length

------------------------- ---------Abel

Ande

Atkinson

Austin

Chen

Dellinger
Dilly
Fleaur

9
5
6

King

Landry

Livingston

10

Last Name

Length

------------------------- ---------Mallin

Markle

Marlow

Marvins

Matos

Mavris

Mccain

Mcewen

Mikkilineni

11

Mourgos

Nayer

Last Name

Length

------------------------- ---------Patel

Russell

Seo
Taylor
Urman

3
6
5

Whalen

28 rows selected.

Ans 17.
SQL> select last_name, months_between(sysdate,hire_date) "Months_Worked" from e
ployees;

LAST_NAME

Months_Worked

------------------------- ------------King

301.933199

Kochhar

274.804167

De Haan

235.062231

Hunold

271.384812

Ernst

254.804167

Austin

181.675134

Pataballa

174.320296

Lorentz

162.25578

Greenberg

215.933199

Faviet

215.965457

Chen

178.57836

LAST_NAME

Months_Worked

------------------------- ------------Sciarra

178.513844

Urman
Popp
Raphaely

173.25578
152.25578
212.25578

Khoo

206.900941

Baida

175.707392

Tobias

180.707392

Himuro
Colmenares
Weiss
Fripp

LAST_NAME

164.997715
156.159005
192.900941
184.159005

Months_Worked

------------------------- ------------Kaufling

207.449328

Vollman

178.159005

Mourgos

152.965457

Nayer
Mikkilineni

180.965457
166.57836

Landry

163

Markle

149.223522

Bissot

179.836425

Atkinson

177.513844

Marlow

185.965457

Olson

160.159005

LAST_NAME

Months_Worked

------------------------- ------------Mallin

194

Rogers

167.642876

Gee
Philtanker
Ladwig

152.094489
150.288038
205

Stiles

177.642876

Seo

174.094489

Patel

172.288038

Rajs

201.933199

Davies

186.546102

Matos

172.997715

LAST_NAME

Months_Worked

------------------------- ------------Vargas

169.191263

Russell

190.449328

Partners

187.320296

Errazuriz

185.159005

Cambrault

153.997715

Zlotkey

150.546102

Tucker

186.513844

Bernstein
Hall

184.707392
179.836425

Olsen

172.513844

Cambrault

164.191263

LAST_NAME

Months_Worked

------------------------- ------------Tuvault

152.739651

King

198.513844

Sully

197.352554

McEwen

192.449328

Smith

185.159005

Doran

175.997715

Sewall

165.384812

Vishney

177.126747

Greene

160.868683

Marvins

150.707392

Lee

LAST_NAME

149.739651

Months_Worked

------------------------- ------------Ande

148.707392

Banda

147.804167

Ozer
Bloom
Fox
Smith

185.126747
172.739651
174.707392
161.739651

Bates
Kumar
Abel
Hutton
Taylor

LAST_NAME

160.707392
147.804167
195.126747
184.868683
172.707392

Months_Worked

------------------------- ------------Livingston
Grant
Johnson

171.739651
158.707392
151.352554

Taylor

174.707392

Fleaur

173.739651

Sullivan

157.804167

Geoni

150.384812

Sarchand
Bull

198.610618
185.836425

Dellinger

169.707392

Cabrio

162.25578

LAST_NAME

Months_Worked

------------------------- ------------Chung
Dilly
Gates

182
180.062231
169.126747

Perkins
Bell

151.868683
198.352554

Everett

185.384812

McCain

169.449328

Jones

160.933199

Walsh

171.707392

Feeney

170.739651

OConnell

157.804167

LAST_NAME

Months_Worked

------------------------- ------------Grant

151.062231

Whalen

298.933199

Hartstein

197.933199

Fay

179.933199

Mavris
Baer
Higgins
Gietz

218.25578
218.25578
218.25578
218.25578

107 rows selected.

Ans 18.
SQL> select last_name,lpad(salary,15,'$') from employees;

LAST_NAME

LPAD(SALARY,15,

------------------------- --------------King

$$$$$$$$$$24000

Kochhar

$$$$$$$$$$17000

De Haan

$$$$$$$$$$17000

Hunold

$$$$$$$$$$$9000

Ernst

$$$$$$$$$$$6000

Austin

$$$$$$$$$$$4800

Pataballa

$$$$$$$$$$$4800

Lorentz

$$$$$$$$$$$4200

Greenberg

$$$$$$$$$$12000

Faviet

$$$$$$$$$$$9000

Chen

$$$$$$$$$$$8200

LAST_NAME

LPAD(SALARY,15,

------------------------- --------------Sciarra
Urman
Popp
Raphaely

$$$$$$$$$$$7700
$$$$$$$$$$$7800
$$$$$$$$$$$6900
$$$$$$$$$$11000

Khoo

$$$$$$$$$$$3100

Baida

$$$$$$$$$$$2900

Tobias

$$$$$$$$$$$2800

Himuro
Colmenares

$$$$$$$$$$$2600
$$$$$$$$$$$2500

Weiss
Fripp

LAST_NAME

$$$$$$$$$$$8000
$$$$$$$$$$$8200

LPAD(SALARY,15,

------------------------- --------------Kaufling

$$$$$$$$$$$7900

Vollman

$$$$$$$$$$$6500

Mourgos

$$$$$$$$$$$5800

Nayer
Mikkilineni

$$$$$$$$$$$3200
$$$$$$$$$$$2700

Landry

$$$$$$$$$$$2400

Markle

$$$$$$$$$$$2200

Bissot

$$$$$$$$$$$3300

Atkinson

$$$$$$$$$$$2800

Marlow

$$$$$$$$$$$2500

Olson

LAST_NAME

$$$$$$$$$$$2100

LPAD(SALARY,15,

------------------------- --------------Mallin

$$$$$$$$$$$3300

Rogers

$$$$$$$$$$$2900

Gee
Philtanker
Ladwig
Stiles

$$$$$$$$$$$2400
$$$$$$$$$$$2200
$$$$$$$$$$$3600
$$$$$$$$$$$3200

Seo

$$$$$$$$$$$2700

Patel

$$$$$$$$$$$2500

Rajs

$$$$$$$$$$$3500

Davies

$$$$$$$$$$$3100

Matos

$$$$$$$$$$$2600

LAST_NAME

LPAD(SALARY,15,

------------------------- --------------Vargas

$$$$$$$$$$$2500

Russell

$$$$$$$$$$14000

Partners

$$$$$$$$$$13500

Errazuriz

$$$$$$$$$$12000

Cambrault

$$$$$$$$$$11000

Zlotkey

$$$$$$$$$$10500

Tucker

$$$$$$$$$$10000

Bernstein
Hall
Olsen
Cambrault

LAST_NAME

$$$$$$$$$$$9500
$$$$$$$$$$$9000
$$$$$$$$$$$8000
$$$$$$$$$$$7500

LPAD(SALARY,15,

------------------------- --------------Tuvault

$$$$$$$$$$$7000

King

$$$$$$$$$$10000

Sully

$$$$$$$$$$$9500

McEwen

$$$$$$$$$$$9000

Smith

$$$$$$$$$$$8000

Doran

$$$$$$$$$$$7500

Sewall

$$$$$$$$$$$7000

Vishney

$$$$$$$$$$10500

Greene

$$$$$$$$$$$9500

Marvins

$$$$$$$$$$$7200

Lee

LAST_NAME

$$$$$$$$$$$6800

LPAD(SALARY,15,

------------------------- --------------Ande

$$$$$$$$$$$6400

Banda

$$$$$$$$$$$6200

Ozer
Bloom
Fox

$$$$$$$$$$11500
$$$$$$$$$$10000
$$$$$$$$$$$9600

Smith

$$$$$$$$$$$7400

Bates

$$$$$$$$$$$7300

Kumar
Abel
Hutton
Taylor

LAST_NAME

$$$$$$$$$$$6100
$$$$$$$$$$11000
$$$$$$$$$$$8800
$$$$$$$$$$$8600

LPAD(SALARY,15,

------------------------- ---------------

Livingston
Grant
Johnson

$$$$$$$$$$$8400
$$$$$$$$$$$7000
$$$$$$$$$$$6200

Taylor

$$$$$$$$$$$3200

Fleaur

$$$$$$$$$$$3100

Sullivan

$$$$$$$$$$$2500

Geoni

$$$$$$$$$$$2800

Sarchand
Bull
Dellinger
Cabrio

LAST_NAME

$$$$$$$$$$$4200
$$$$$$$$$$$4100
$$$$$$$$$$$3400
$$$$$$$$$$$3000

LPAD(SALARY,15,

------------------------- --------------Chung
Dilly

$$$$$$$$$$$3800
$$$$$$$$$$$3600

Gates

$$$$$$$$$$$2900

Perkins

$$$$$$$$$$$2500

Bell
Everett
McCain

$$$$$$$$$$$4000
$$$$$$$$$$$3900
$$$$$$$$$$$3200

Jones

$$$$$$$$$$$2800

Walsh

$$$$$$$$$$$3100

Feeney

$$$$$$$$$$$3000

OConnell

$$$$$$$$$$$2600

LAST_NAME

LPAD(SALARY,15,

------------------------- --------------Grant

$$$$$$$$$$$2600

Whalen

$$$$$$$$$$$4400

Hartstein

$$$$$$$$$$13000

Fay
Mavris
Baer
Higgins
Gietz

$$$$$$$$$$$6000
$$$$$$$$$$$6500
$$$$$$$$$$10000
$$$$$$$$$$12000
$$$$$$$$$$$8300

107 rows selected.

Ans 20.
SQL> select last_name,round(months_between(sysdate,hire_date)/7,0) "TENURE" from
employees order by TENURE desc;

LAST_NAME

TENURE

------------------------- ---------King

43

Whalen

43

Kochhar

39

Hunold

39

Ernst

36

De Haan

34

Greenberg

31

Faviet

31

Mavris

31

Baer
Higgins

31
31

LAST_NAME

TENURE

------------------------- ---------Gietz

31

Raphaely

30

Kaufling

30

Khoo

30

Rajs

29

Ladwig

29

Weiss

28

Mallin

28

King

28

Hartstein
Abel

28
28

LAST_NAME

TENURE

------------------------- ---------Sarchand
Bell

28
28

Sully

28

Marlow

27

Davies

27

Russell

27

Bull
Tucker

27
27

McEwen
Partners
Austin

27
27
26

LAST_NAME

TENURE

------------------------- ---------Fay

26

Sciarra

26

Tobias

26

Fripp

26

Nayer

26

Bissot

26

Errazuriz

26

Bernstein
Hall

26
26

Smith

26

Ozer

26

LAST_NAME

TENURE

------------------------- ---------Hutton

26

Chung

26

Dilly

26

Everett

26

Chen

26

Pataballa

25

Walsh

25

Baida

25

Vollman

25

Atkinson

25

Stiles

25

LAST_NAME

TENURE

------------------------- ---------Seo

25

Patel

25

Matos

25

Olsen

25

Doran

25

Vishney

25

Bloom

25

Fox
Taylor
Livingston

25
25
25

Taylor

LAST_NAME

25

TENURE

------------------------- ---------Fleaur

25

Urman

25

Himuro

24

Mikkilineni

24

Rogers

24

Vargas

24

Feeney

24

Dellinger

24

Gates
McCain
Sewall

LAST_NAME

24
24
24

TENURE

------------------------- ---------Lorentz

23

Landry

23

Olson

23

Cambrault

23

Greene

23

OConnell

23

Bates

23

Grant

23

Sullivan

23

Cabrio

23

Jones

23

LAST_NAME

TENURE

------------------------- ---------Smith

23

Popp

22

Colmenares

22

Mourgos
Gee

22
22

Cambrault

22

Grant

22

Tuvault

22

Marvins

22

Johnson

22

Perkins

22

LAST_NAME

TENURE

------------------------- ---------Zlotkey

22

Markle

21

Philtanker
Lee

21
21

Geoni

21

Banda

21

Kumar

21

Ande

21

107 rows selected.


Ans 20.
SQL> select lpad(last_name,8,' ') "EMPLOYEES_AND_THEIR_SALARIES",lpad('*',trunc(
salary/1000),'*') from employees order by salary desc;

EMPLOYEE
-------LPAD('*',TRUNC(SALARY/1000),'*')
--------------------------------------------------------------------------------------------------Markle
**

Olson
**

107 rows selected.

Ans 21.
SQL> select last_name,hire_date,next_day(add_months(hire_date,6),'Mon') "Salary
Review Date" from employees;

LAST_NAME

HIRE_DATE Salary Re

------------------------- --------- --------King

17-JUN-87 21-DEC-87

Kochhar

21-SEP-89 26-MAR-90

De Haan

13-JAN-93 19-JUL-93

Hunold

03-JAN-90 09-JUL-90

Ernst

21-MAY-91 25-NOV-91

Austin

25-JUN-97 29-DEC-97

Pataballa

05-FEB-98 10-AUG-98

Lorentz

07-FEB-99 09-AUG-99

Greenberg

17-AUG-94 20-FEB-95

Faviet

16-AUG-94 20-FEB-95

Chen

28-SEP-97 30-MAR-98

LAST_NAME

HIRE_DATE Salary Re

------------------------- --------- --------Sciarra


Urman
Popp
Raphaely
Khoo

30-SEP-97 06-APR-98
07-MAR-98 14-SEP-98
07-DEC-99 12-JUN-00
07-DEC-94 12-JUN-95
18-MAY-95 20-NOV-95

Baida

24-DEC-97 29-JUN-98

Tobias

24-JUL-97 26-JAN-98

Himuro
Colmenares

15-NOV-98 17-MAY-99
10-AUG-99 14-FEB-00

Weiss

18-JUL-96 20-JAN-97

Fripp

10-APR-97 13-OCT-97

LAST_NAME

HIRE_DATE Salary Re

------------------------- --------- --------Kaufling

01-MAY-95 06-NOV-95

Vollman

10-OCT-97 13-APR-98

Mourgos

16-NOV-99 22-MAY-00

Nayer
Mikkilineni

16-JUL-97 19-JAN-98
28-SEP-98 29-MAR-99

Landry

14-JAN-99 19-JUL-99

Markle

08-MAR-00 11-SEP-00

Bissot

20-AUG-97 23-FEB-98

Atkinson

30-OCT-97 04-MAY-98

Marlow

16-FEB-97 18-AUG-97

Olson

LAST_NAME

10-APR-99 11-OCT-99

HIRE_DATE Salary Re

------------------------- --------- --------Mallin

14-JUN-96 16-DEC-96

Rogers

26-AUG-98 01-MAR-99

Gee
Philtanker
Ladwig

12-DEC-99 19-JUN-00
06-FEB-00 07-AUG-00
14-JUL-95 15-JAN-96

Stiles

26-OCT-97 27-APR-98

Seo

12-FEB-98 17-AUG-98

Patel

06-APR-98 12-OCT-98

Rajs

17-OCT-95 22-APR-96

Davies

29-JAN-97 04-AUG-97

Matos

15-MAR-98 21-SEP-98

LAST_NAME

HIRE_DATE Salary Re

------------------------- --------- --------Vargas

09-JUL-98 11-JAN-99

Russell

01-OCT-96 07-APR-97

Partners

05-JAN-97 07-JUL-97

Errazuriz

10-MAR-97 15-SEP-97

Cambrault

15-OCT-99 17-APR-00

Zlotkey

29-JAN-00 31-JUL-00

Tucker

30-JAN-97 04-AUG-97

Bernstein
Hall
Olsen
Cambrault

LAST_NAME

24-MAR-97 29-SEP-97
20-AUG-97 23-FEB-98
30-MAR-98 05-OCT-98
09-DEC-98 14-JUN-99

HIRE_DATE Salary Re

------------------------- --------- --------Tuvault

23-NOV-99 29-MAY-00

King

30-JAN-96 05-AUG-96

Sully

04-MAR-96 09-SEP-96

McEwen

01-AUG-96 03-FEB-97

Smith

10-MAR-97 15-SEP-97

Doran

15-DEC-97 22-JUN-98

Sewall

03-NOV-98 10-MAY-99

Vishney

11-NOV-97 18-MAY-98

Greene

19-MAR-99 20-SEP-99

Marvins

24-JAN-00 31-JUL-00

Lee

LAST_NAME

23-FEB-00 28-AUG-00

HIRE_DATE Salary Re

------------------------- --------- --------Ande

24-MAR-00 25-SEP-00

Banda

21-APR-00 23-OCT-00

Ozer
Bloom
Fox

11-MAR-97 15-SEP-97
23-MAR-98 28-SEP-98
24-JAN-98 27-JUL-98

Smith

23-FEB-99 30-AUG-99

Bates

24-MAR-99 27-SEP-99

Kumar
Abel
Hutton

21-APR-00 23-OCT-00
11-MAY-96 18-NOV-96
19-MAR-97 22-SEP-97

Taylor

LAST_NAME

24-MAR-98 28-SEP-98

HIRE_DATE Salary Re

------------------------- --------- --------Livingston


Grant
Johnson

23-APR-98 26-OCT-98
24-MAY-99 29-NOV-99
04-JAN-00 10-JUL-00

Taylor

24-JAN-98 27-JUL-98

Fleaur

23-FEB-98 24-AUG-98

Sullivan

21-JUN-99 27-DEC-99

Geoni

03-FEB-00 07-AUG-00

Sarchand
Bull
Dellinger
Cabrio

LAST_NAME

27-JAN-96 29-JUL-96
20-FEB-97 25-AUG-97
24-JUN-98 28-DEC-98
07-FEB-99 09-AUG-99

HIRE_DATE Salary Re

------------------------- --------- --------Chung


Dilly

14-JUN-97 15-DEC-97
13-AUG-97 16-FEB-98

Gates

11-JUL-98 18-JAN-99

Perkins

19-DEC-99 26-JUN-00

Bell

04-FEB-96 05-AUG-96

Everett

03-MAR-97 08-SEP-97

McCain

01-JUL-98 04-JAN-99

Jones

17-MAR-99 20-SEP-99

Walsh

24-APR-98 26-OCT-98

Feeney

23-MAY-98 30-NOV-98

OConnell

21-JUN-99 27-DEC-99

LAST_NAME

HIRE_DATE Salary Re

------------------------- --------- --------Grant

13-JAN-00 17-JUL-00

Whalen

17-SEP-87 21-MAR-88

Hartstein

17-FEB-96 19-AUG-96

Fay
Mavris
Baer
Higgins
Gietz

17-AUG-97 23-FEB-98
07-JUN-94 12-DEC-94
07-JUN-94 12-DEC-94
07-JUN-94 12-DEC-94
07-JUN-94 12-DEC-94

107 rows selected.

Ans 22.
SQL> select last_name,hire_date,to_char(hire_date,'day') "Day of the Week" from
employees;

LAST_NAME

HIRE_DATE Day of th

------------------------- --------- --------King

17-JUN-87 wednesday

Kochhar

21-SEP-89 thursday

De Haan

13-JAN-93 wednesday

Hunold

03-JAN-90 wednesday

Ernst

21-MAY-91 tuesday

Austin

25-JUN-97 wednesday

Pataballa

05-FEB-98 thursday

Lorentz

07-FEB-99 sunday

Greenberg

17-AUG-94 wednesday

Faviet

16-AUG-94 tuesday

Chen

28-SEP-97 sunday

LAST_NAME

HIRE_DATE Day of th

------------------------- --------- --------Sciarra


Urman
Popp
Raphaely

30-SEP-97 tuesday
07-MAR-98 saturday
07-DEC-99 tuesday
07-DEC-94 wednesday

Khoo

18-MAY-95 thursday

Baida

24-DEC-97 wednesday

Tobias

24-JUL-97 thursday

Himuro
Colmenares

15-NOV-98 sunday
10-AUG-99 tuesday

Weiss

18-JUL-96 thursday

Fripp

10-APR-97 thursday

LAST_NAME

HIRE_DATE Day of th

------------------------- --------- --------Kaufling

01-MAY-95 monday

Vollman

10-OCT-97 friday

Mourgos

16-NOV-99 tuesday

Nayer
Mikkilineni

16-JUL-97 wednesday
28-SEP-98 monday

Landry

14-JAN-99 thursday

Markle

08-MAR-00 wednesday

Bissot

20-AUG-97 wednesday

Atkinson

30-OCT-97 thursday

Marlow

16-FEB-97 sunday

Olson

LAST_NAME

10-APR-99 saturday

HIRE_DATE Day of th

------------------------- --------- --------Mallin

14-JUN-96 friday

Rogers

26-AUG-98 wednesday

Gee
Philtanker
Ladwig

12-DEC-99 sunday
06-FEB-00 sunday
14-JUL-95 friday

Stiles

26-OCT-97 sunday

Seo

12-FEB-98 thursday

Patel

06-APR-98 monday

Rajs

17-OCT-95 tuesday

Davies

29-JAN-97 wednesday

Matos

15-MAR-98 sunday

LAST_NAME

HIRE_DATE Day of th

------------------------- --------- --------Vargas

09-JUL-98 thursday

Russell

01-OCT-96 tuesday

Partners

05-JAN-97 sunday

Errazuriz

10-MAR-97 monday

Cambrault

15-OCT-99 friday

Zlotkey

29-JAN-00 saturday

Tucker

30-JAN-97 thursday

Bernstein
Hall
Olsen
Cambrault

LAST_NAME

24-MAR-97 monday
20-AUG-97 wednesday
30-MAR-98 monday
09-DEC-98 wednesday

HIRE_DATE Day of th

------------------------- --------- --------Tuvault

23-NOV-99 tuesday

King

30-JAN-96 tuesday

Sully

04-MAR-96 monday

McEwen

01-AUG-96 thursday

Smith

10-MAR-97 monday

Doran

15-DEC-97 monday

Sewall

03-NOV-98 tuesday

Vishney

11-NOV-97 tuesday

Greene

19-MAR-99 friday

Marvins

24-JAN-00 monday

Lee

LAST_NAME

23-FEB-00 wednesday

HIRE_DATE Day of th

------------------------- --------- --------Ande

24-MAR-00 friday

Banda

21-APR-00 friday

Ozer
Bloom
Fox

11-MAR-97 tuesday
23-MAR-98 monday
24-JAN-98 saturday

Smith

23-FEB-99 tuesday

Bates

24-MAR-99 wednesday

Kumar
Abel
Hutton
Taylor

LAST_NAME

21-APR-00 friday
11-MAY-96 saturday
19-MAR-97 wednesday
24-MAR-98 tuesday

HIRE_DATE Day of th

------------------------- --------- --------Livingston


Grant
Johnson

23-APR-98 thursday
24-MAY-99 monday
04-JAN-00 tuesday

Taylor

24-JAN-98 saturday

Fleaur

23-FEB-98 monday

Sullivan

21-JUN-99 monday

Geoni

03-FEB-00 thursday

Sarchand
Bull
Dellinger
Cabrio

LAST_NAME

27-JAN-96 saturday
20-FEB-97 thursday
24-JUN-98 wednesday
07-FEB-99 sunday

HIRE_DATE Day of th

------------------------- --------- --------Chung

14-JUN-97 saturday

Dilly

13-AUG-97 wednesday

Gates

11-JUL-98 saturday

Perkins

19-DEC-99 sunday

Bell
Everett
McCain

04-FEB-96 sunday
03-MAR-97 monday
01-JUL-98 wednesday

Jones

17-MAR-99 wednesday

Walsh

24-APR-98 friday

Feeney

23-MAY-98 saturday

OConnell

LAST_NAME

21-JUN-99 monday

HIRE_DATE Day of th

------------------------- --------- ---------

Grant

13-JAN-00 thursday

Whalen

17-SEP-87 thursday

Hartstein

17-FEB-96 saturday

Fay
Mavris
Baer
Higgins
Gietz

17-AUG-97 sunday
07-JUN-94 tuesday
07-JUN-94 tuesday
07-JUN-94 tuesday
07-JUN-94 tuesday

107 rows selected.

Ans 23.
SQL> select last_name,nvl(commission_pct,No Commission) "commission" from employees;

Ans 24.
SQL> select first_name,last_name,max(salary) "Maximum",min(salary) "Minimum",su
m(salary) "Sum",round(avg(salary),0) "Average" from employees;

ans 25.
SQL> select count(*),j.job_title from employees e,employees w,jobs j where e.jo
_id=w.job_id group by j.job_title;

COUNT(*) JOB_TITLE
---------- ----------------------------------1839 Accounting Manager

1839 Sales Representative


1839 Purchasing Clerk
1839 Programmer
1839 Public Relations Representative
1839 Administration Vice President
1839 Stock Manager
1839 Marketing Representative
1839 President
1839 Administration Assistant
1839 Finance Manager

COUNT(*) JOB_TITLE
---------- ----------------------------------1839 Purchasing Manager
1839 Human Resources Representative
1839 Accountant
1839 Stock Clerk
1839 Shipping Clerk
1839 Public Accountant
1839 Sales Manager
1839 Marketing Manager

19 rows selected.

SQL> select count(distinct(manager_id)) from employees;

COUNT(DISTINCT(MANAGER_ID))
--------------------------18
Ans 27.
SQL> select (max(salary)-min(salary)) "Difference" from employees;

Difference
---------21900
cr
Ans 28 .
SQL> select m.employee_id,min(e.salary) from employees e,employees m where e.man
ager_id=m.employee_id group by m.employee_id having min(e.salary) >6000 order by
min(e.salary) desc;

EMPLOYEE_ID MIN(E.SALARY)
----------- ------------102

9000

205

8300

145

7000

146

7000

108

6900

147

6200

149

6200

148

6100

8 rows selected.

Ans 29.
SQL> select ((count(decode(to_char(hire_date,'YYYY'),1995,'c1')))+(count(decode(
to_char(hire_date,'YYYY'),1996,'c2')))+(count(decode(to_char(hire_date,'YYYY'),1
997,'c3')))+(count(decode(to_char(hire_date,'YYYY'),1998,'c4')))) "Total",count(
decode(to_char(hire_date,'YYYY'),1995,'c1')) "1995",count(decode(to_char(hire_da
te,'YYYY'),1996,'c2')) "1996",count(decode(to_char(hire_date,'YYYY'),1997,'c3'))
"1997",count(decode(to_char(hire_date,'YYYY'),1998,'c4')) "1998" from employees
;

Total

1995

1996

1997

1998

---------- ---------- ---------- ---------- ---------65

10

28

23

Ans 30.
SQL> select * from (select j.job_title,sum(decode(department_id,20,salary))"Dept
20",sum(decode(department_id,50,salary))"Dept 50",sum(decode(department_id,80,s
alary))"Dept 80",sum(decode(department_id,90,salary))"Dept 90",sum(salary) "Tota
l"from employees,jobs j group by j.job_title) order by 1;

JOB_TITLE

Dept 20 Dept 50 Dept 80 Dept 90

Total
----------------------------------- ---------- ---------- ---------- ------------------Accountant

19000

156400

304500

58000

691400
Accounting Manager

19000

156400

304500

58000

19000

156400

304500

58000

691400
Administration Assistant
691400
Administration Vice President

19000

156400

304500

58000

691400
Finance Manager

19000

156400

304500

58000

691400
Human Resources Representative

19000

156400

304500

58000

691400
Marketing Manager

19000

156400

304500

58000

691400
Marketing Representative

19000

156400

304500

58000

691400
President

19000

156400

304500

58000

691400
Programmer

19000

156400

304500

58000

691400
Public Accountant

19000

156400

304500

58000

691400

JOB_TITLE

Dept 20 Dept 50 Dept 80 Dept 90

Total
----------------------------------- ---------- ---------- ---------- ------------------Public Relations Representative

19000

156400

304500

58000

691400
Purchasing Clerk

19000

156400

304500

58000

691400
Purchasing Manager

19000

156400

304500

58000

691400
Sales Manager

19000

156400

304500

58000

691400
Sales Representative

19000

156400

304500

58000

691400
Shipping Clerk

19000

156400

304500

58000

691400
Stock Clerk

19000

156400

304500

58000

691400
Stock Manager
691400

19 rows selected.
Ans 31.

19000

156400

304500

58000

SQL> select l.location_id,l.street_address,l.city,l.state_province,c.country_nam


e from locations l,countries c where l.country_id=c.country_id;

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------2200 12-98 Victoria Street
Sydney

New South Wales

Australia

2800 Rua Frei Caneca 1360


Sao Paulo

Sao Paulo

Brazil

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
----------------------------------------

1800 147 Spadina Ave

Toronto

Ontario

Canada

1900 6092 Boxwood St


Whitehorse

Yukon

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------Canada

2900 20 Rue des Corps-Saints


Geneva

Geneve

Switzerland

3000 Murtenstrasse 921

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME

---------------------------------------Bern

BE

Switzerland

2000 40-5-12 Laogianggen


Beijing
China

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------2700 Schwanthalerstr. 7031
Munich

Bavaria

Germany

2100 1298 Vileparle (E)


Bombay

Maharashtra

India

LOCATION_ID STREET_ADDRESS
----------- ----------------------------------------

CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
----------------------------------------

1000 1297 Via Cola di Rie


Roma
Italy

1100 93091 Calle della Testa


Venice

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------Italy

1200 2017 Shinjuku-ku


Tokyo

Tokyo Prefecture

Japan

1300 9450 Kamiya-cho

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------Hiroshima
Japan

3200 Mariano Escobedo 9991


Mexico City

Distrito Federal,

Mexico

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------3100 Pieter Breughelstraat 837
Utrecht
Netherlands

Utrecht

2300 198 Clementi North


Singapore
Singapore

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
----------------------------------------

2400 8204 Arthur St


London
United Kingdom

2500 Magdalen Centre, The Oxford Science Park


Oxford

Oxford

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------United Kingdom

2600 9702 Chester Road


Stretford

Manchester

United Kingdom

1400 2014 Jabberwocky Rd

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
---------------------------------------Southlake

Texas

United States of America

1500 2011 Interiors Blvd


South San Francisco

California

United States of America

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ -------------------------

COUNTRY_NAME
---------------------------------------1600 2007 Zagora St
South Brunswick

New Jersey

United States of America

1700 2004 Charade Rd


Seattle

Washington

United States of America

LOCATION_ID STREET_ADDRESS
----------- ---------------------------------------CITY

STATE_PROVINCE

------------------------------ ------------------------COUNTRY_NAME
----------------------------------------

23 rows selected.
Ans 32.
SQL> select e.last_name,j.job_title,e.department_id,d.department_name from emplo
yees e,locations l,departments d,jobs j where e.department_id=d.department_id an
d d.location_id=l.location_id and l.city='Toronto';

LAST_NAME

JOB_TITLE

DEPARTMENT_ID DEPA

RTMENT_NAME
------------------------- ----------------------------------- ------------- ----------------------------Hartstein

Public Relations Representative

20 Mark

eting
Hartstein

Human Resources Representative

20 Mark

eting
Hartstein

Marketing Representative

20 Mark

eting
Hartstein

Marketing Manager

20 Mark

eting
Hartstein

Programmer

20 Mark

Shipping Clerk

20 Mark

eting
Hartstein
eting
Hartstein

Stock Clerk

20 Mark

eting
Hartstein

Stock Manager

20 Mark

Purchasing Clerk

20 Mark

eting
Hartstein
eting
Hartstein

Purchasing Manager

20 Mark

eting
Hartstein
eting

Sales Representative

20 Mark

LAST_NAME

JOB_TITLE

DEPARTMENT_ID DEPA

RTMENT_NAME
------------------------- ----------------------------------- ------------- ----------------------------Hartstein

Sales Manager

20 Mark

eting
Hartstein

Public Accountant

20 Mark

eting
Hartstein

Accounting Manager

20 Mark

eting
Hartstein

Accountant

20 Mark

eting
Hartstein

Finance Manager

20 Mark

eting
Hartstein

Administration Assistant

20 Mark

eting
Hartstein

Administration Vice President

20 Mark

eting
Hartstein

President

20 Mark

eting
Fay

Public Relations Representative

20 Mark

eting
Fay
eting

Human Resources Representative

20 Mark

Fay

Marketing Representative

20 Mark

eting

LAST_NAME

JOB_TITLE

DEPARTMENT_ID DEPA

RTMENT_NAME
------------------------- ----------------------------------- ------------- ----------------------------Fay

Marketing Manager

20 Mark

eting
Fay

Programmer

20 Mark

Shipping Clerk

20 Mark

eting
Fay
eting
Fay

Stock Clerk

20 Mark

eting
Fay

Stock Manager

20 Mark

Purchasing Clerk

20 Mark

eting
Fay
eting
Fay

Purchasing Manager

20 Mark

eting
Fay

Sales Representative

20 Mark

eting
Fay
eting

Sales Manager

20 Mark

Fay

Public Accountant

20 Mark

eting
Fay

Accounting Manager

20 Mark

eting

LAST_NAME

JOB_TITLE

DEPARTMENT_ID DEPA

RTMENT_NAME
------------------------- ----------------------------------- ------------- ----------------------------Fay

Accountant

20 Mark

eting
Fay

Finance Manager

20 Mark

eting
Fay

Administration Assistant

20 Mark

eting
Fay

Administration Vice President

20 Mark

eting
Fay

President

20 Mark

eting

38 rows selected.

Ans 33.

SQL> select w.last_name "Employee Last Name",w.employee_id "Employee ID",e.last_

name "manager Last Name", e.manager_id "Manager ID" from employees w,employees e
where w.manager_id=e.employee_id;

Employee Last Name

Employee ID manager Last Name

Manager ID

------------------------- ----------- ------------------------- ---------Kochhar

101 King

De Haan

102 King

Hunold

103 De Haan

100

Ernst

104 Hunold

102

Austin

105 Hunold

102

Pataballa

106 Hunold

102

Lorentz

107 Hunold

102

Greenberg

108 Kochhar

100

Faviet

109 Greenberg

101

Chen

110 Greenberg

101

Sciarra

111 Greenberg

101

Employee Last Name

Employee ID manager Last Name

------------------------- ----------- ------------------------- ---------Urman


Popp
Raphaely

112 Greenberg
113 Greenberg

101
101

114 King

Khoo

115 Raphaely

100

Baida

116 Raphaely

100

Tobias

117 Raphaely

100

Manager ID

Himuro
Colmenares
Weiss
Fripp
Kaufling

Employee Last Name

118 Raphaely

100

119 Raphaely

100

120 King
121 King
122 King

Employee ID manager Last Name

Manager ID

------------------------- ----------- ------------------------- ---------Vollman

123 King

Mourgos

124 King

Nayer
Mikkilineni

125 Weiss
126 Weiss

100
100

Landry

127 Weiss

100

Markle

128 Weiss

100

Bissot

129 Fripp

100

Atkinson

130 Fripp

100

Marlow

131 Fripp

100

Olson

132 Fripp

Mallin

133 Kaufling

Employee Last Name

100
100

Employee ID manager Last Name

------------------------- ----------- ------------------------- ---------Rogers


Gee
Philtanker

134 Kaufling
135 Kaufling
136 Kaufling

100
100
100

Manager ID

Ladwig

137 Vollman

100

Stiles

138 Vollman

100

Seo

139 Vollman

100

Patel

140 Vollman

100

Rajs

141 Mourgos

100

Davies

142 Mourgos

100

Matos

143 Mourgos

100

Vargas

144 Mourgos

100

Employee Last Name

Employee ID manager Last Name

Manager ID

------------------------- ----------- ------------------------- ---------Russell

145 King

Partners

146 King

Errazuriz

147 King

Cambrault

148 King

Zlotkey

149 King

Tucker

150 Russell

Bernstein
Hall

151 Russell
152 Russell

Olsen
Cambrault
Tuvault

Employee Last Name

153 Russell
154 Russell
155 Russell

100
100
100
100
100
100

Employee ID manager Last Name

------------------------- ----------- ------------------------- ----------

Manager ID

King

156 Partners

100

Sully

157 Partners

100

McEwen

158 Partners

100

Smith

159 Partners

100

Doran

160 Partners

100

Sewall

161 Partners

100

Vishney

162 Errazuriz

100

Greene

163 Errazuriz

100

Marvins

164 Errazuriz

100

Lee

165 Errazuriz

Ande

166 Errazuriz

Employee Last Name

100
100

Employee ID manager Last Name

------------------------- ----------- ------------------------- ---------Banda


Ozer
Bloom
Fox

167 Errazuriz

100

168 Cambrault

100

169 Cambrault
170 Cambrault

100
100

Smith

171 Cambrault

100

Bates

172 Cambrault

100

Kumar
Abel
Hutton
Taylor
Livingston

173 Cambrault
174 Zlotkey
175 Zlotkey
176 Zlotkey
177 Zlotkey

100
100
100
100
100

Manager ID

Employee Last Name

Employee ID manager Last Name

Manager ID

------------------------- ----------- ------------------------- ---------Grant

178 Zlotkey

Johnson

100

179 Zlotkey

100

Taylor

180 Weiss

100

Fleaur

181 Weiss

100

Sullivan

182 Weiss

100

Geoni

183 Weiss

100

Sarchand
Bull

184 Fripp
185 Fripp

Dellinger

186 Fripp

Cabrio

187 Fripp

Chung

188 Kaufling

Employee Last Name

100
100
100
100
100

Employee ID manager Last Name

------------------------- ----------- ------------------------- ---------Dilly

189 Kaufling

100

Gates

190 Kaufling

100

Perkins

191 Kaufling

100

Bell
Everett
McCain

192 Vollman
193 Vollman
194 Vollman

Jones

195 Vollman

Walsh

196 Mourgos

100
100
100
100
100

Manager ID

Feeney

197 Mourgos

OConnell

100

198 Mourgos

Grant

199 Mourgos

Employee Last Name

100
100

Employee ID manager Last Name

Manager ID

------------------------- ----------- ------------------------- ---------Whalen

200 Kochhar

Hartstein

201 King

Fay
Mavris
Baer
Higgins
Gietz

202 Hartstein
203 Kochhar
204 Kochhar
205 Kochhar
206 Higgins

100

100
100
100
100
101

106 rows selected.

Ans 34.

Ans 35.
SQL> select e.last_name,e.hire_date from employees e where e.hire_date > (select
hire_date from employees where last_name='Davies');

LAST_NAME

HIRE_DATE

------------------------- ---------

Austin

25-JUN-97

Pataballa

05-FEB-98

Lorentz

07-FEB-99

Chen

28-SEP-97

Sciarra

30-SEP-97

Urman

07-MAR-98

Popp

07-DEC-99

Baida

24-DEC-97

Tobias

24-JUL-97

Himuro
Colmenares

LAST_NAME

15-NOV-98
10-AUG-99

HIRE_DATE

------------------------- --------Fripp

10-APR-97

Vollman

10-OCT-97

Mourgos

16-NOV-99

Nayer
Mikkilineni

16-JUL-97
28-SEP-98

Landry

14-JAN-99

Markle

08-MAR-00

Bissot

20-AUG-97

Atkinson

30-OCT-97

Marlow

16-FEB-97

Olson

10-APR-99

LAST_NAME

HIRE_DATE

------------------------- --------Rogers
Gee
Philtanker

26-AUG-98
12-DEC-99
06-FEB-00

Stiles

26-OCT-97

Seo

12-FEB-98

Patel

06-APR-98

Matos

15-MAR-98

Vargas

09-JUL-98

Errazuriz

10-MAR-97

Cambrault
Zlotkey

LAST_NAME

15-OCT-99
29-JAN-00

HIRE_DATE

------------------------- --------Tucker
Bernstein
Hall
Olsen
Cambrault

30-JAN-97
24-MAR-97
20-AUG-97
30-MAR-98
09-DEC-98

Tuvault

23-NOV-99

Smith

10-MAR-97

Doran

15-DEC-97

Sewall

03-NOV-98

Vishney

11-NOV-97

Greene

19-MAR-99

LAST_NAME

HIRE_DATE

------------------------- --------Marvins
Lee

24-JAN-00
23-FEB-00

Ande

24-MAR-00

Banda

21-APR-00

Ozer
Bloom
Fox

11-MAR-97
23-MAR-98
24-JAN-98

Smith

23-FEB-99

Bates

24-MAR-99

Kumar

21-APR-00

Hutton

19-MAR-97

LAST_NAME

HIRE_DATE

------------------------- --------Taylor
Livingston
Grant
Johnson
Taylor

24-MAR-98
23-APR-98
24-MAY-99
04-JAN-00
24-JAN-98

Fleaur

23-FEB-98

Sullivan

21-JUN-99

Geoni

03-FEB-00

Bull
Dellinger
Cabrio

LAST_NAME

20-FEB-97
24-JUN-98
07-FEB-99

HIRE_DATE

------------------------- --------Chung
Dilly

14-JUN-97
13-AUG-97

Gates

11-JUL-98

Perkins

19-DEC-99

Everett

03-MAR-97

McCain

01-JUL-98

Jones

17-MAR-99

Walsh

24-APR-98

Feeney

23-MAY-98

OConnell
Grant

LAST_NAME

21-JUN-99
13-JAN-00

HIRE_DATE

------------------------- --------Fay

17-AUG-97

78 rows selected.

Ans 36.
SQL> select e.employee_id,e.last_name,e.salary from employees e where e.salary>(
select avg(salary) from employees where e.department_id=department_id);

EMPLOYEE_ID LAST_NAME

SALARY

----------- ------------------------- ---------100 King


103 Hunold
104 Ernst
108 Greenberg
109 Faviet
114 Raphaely
120 Weiss
121 Fripp
122 Kaufling

24000
9000
6000
12000
9000
11000
8000
8200
7900

123 Vollman

6500

124 Mourgos

5800

EMPLOYEE_ID LAST_NAME

SALARY

----------- ------------------------- ---------137 Ladwig

3600

141 Rajs

3500

145 Russell

14000

146 Partners

13500

147 Errazuriz

12000

148 Cambrault

11000

149 Zlotkey

10500

150 Tucker

10000

151 Bernstein

9500

152 Hall

9000

156 King

10000

EMPLOYEE_ID LAST_NAME

SALARY

----------- ------------------------- ---------157 Sully


158 McEwen

9500
9000

162 Vishney

10500

163 Greene

9500

168 Ozer
169 Bloom

11500
10000

170 Fox

9600

174 Abel

11000

184 Sarchand
185 Bull
188 Chung

4200
4100
3800

EMPLOYEE_ID LAST_NAME
----------- ------------------------- ----------

SALARY

189 Dilly

3600

192 Bell

4000

193 Everett

3900

201 Hartstein

13000

205 Higgins

12000

38 rows selected.

Ans 37.
SQL> select e.employee_id,e.last_name from employees e where e.department_id in
(select department_id from employees where last_name like '%u%');

EMPLOYEE_ID LAST_NAME
----------- ------------------------107 Lorentz
106 Pataballa
105 Austin
104 Ernst
103 Hunold
119 Colmenares
118 Himuro
117 Tobias
116 Baida
115 Khoo
114 Raphaely

EMPLOYEE_ID LAST_NAME
----------- ------------------------199 Grant
198 OConnell
197 Feeney
196 Walsh
195 Jones
194 McCain
193 Everett
192 Bell
191 Perkins
190 Gates
189 Dilly

EMPLOYEE_ID LAST_NAME
----------- ------------------------188 Chung
187 Cabrio
186 Dellinger
185 Bull
184 Sarchand
183 Geoni
182 Sullivan
181 Fleaur

180 Taylor
144 Vargas
143 Matos

EMPLOYEE_ID LAST_NAME
----------- ------------------------142 Davies
141 Rajs
140 Patel
139 Seo
138 Stiles
137 Ladwig
136 Philtanker
135 Gee
134 Rogers
133 Mallin
132 Olson

EMPLOYEE_ID LAST_NAME
----------- ------------------------131 Marlow
130 Atkinson
129 Bissot
128 Markle
127 Landry

126 Mikkilineni
125 Nayer
124 Mourgos
123 Vollman
122 Kaufling
121 Fripp

EMPLOYEE_ID LAST_NAME
----------- ------------------------120 Weiss
179 Johnson
177 Livingston
176 Taylor
175 Hutton
174 Abel
173 Kumar
172 Bates
171 Smith
170 Fox
169 Bloom

EMPLOYEE_ID LAST_NAME
----------- ------------------------168 Ozer
167 Banda

166 Ande
165 Lee
164 Marvins
163 Greene
162 Vishney
161 Sewall
160 Doran
159 Smith
158 McEwen

EMPLOYEE_ID LAST_NAME
----------- ------------------------157 Sully
156 King
155 Tuvault
154 Cambrault
153 Olsen
152 Hall
151 Bernstein
150 Tucker
149 Zlotkey
148 Cambrault
147 Errazuriz

EMPLOYEE_ID LAST_NAME

----------- ------------------------146 Partners


145 Russell

90 rows selected.

Ans 38.
SQL> select e.last_name,e.department_id,e.job_id from employees e,departments d,
locations l where e.department_id=d.department_id and d.location_id=l.location_i
d;

LAST_NAME

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------King

90 AD_PRES

Kochhar

90 AD_VP

De Haan

90 AD_VP

Hunold

60 IT_PROG

Ernst

60 IT_PROG

Austin

60 IT_PROG

Pataballa

60 IT_PROG

Lorentz

60 IT_PROG

Greenberg

100 FI_MGR

Faviet

100 FI_ACCOUNT

Chen

100 FI_ACCOUNT

LAST_NAME

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Sciarra


Urman
Popp
Raphaely

100 FI_ACCOUNT
100 FI_ACCOUNT
100 FI_ACCOUNT
30 PU_MAN

Khoo

30 PU_CLERK

Baida

30 PU_CLERK

Tobias

30 PU_CLERK

Himuro
Colmenares
Weiss
Fripp

LAST_NAME

30 PU_CLERK
30 PU_CLERK
50 ST_MAN
50 ST_MAN

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Kaufling

50 ST_MAN

Vollman

50 ST_MAN

Mourgos

50 ST_MAN

Nayer
Mikkilineni

50 ST_CLERK
50 ST_CLERK

Landry

50 ST_CLERK

Markle

50 ST_CLERK

Bissot
Atkinson

50 ST_CLERK
50 ST_CLERK

Marlow
Olson

LAST_NAME

50 ST_CLERK
50 ST_CLERK

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Mallin

50 ST_CLERK

Rogers

50 ST_CLERK

Gee
Philtanker
Ladwig

50 ST_CLERK
50 ST_CLERK
50 ST_CLERK

Stiles

50 ST_CLERK

Seo

50 ST_CLERK

Patel

50 ST_CLERK

Rajs

50 ST_CLERK

Davies

50 ST_CLERK

Matos

50 ST_CLERK

LAST_NAME

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Vargas

50 ST_CLERK

Russell

80 SA_MAN

Partners

80 SA_MAN

Errazuriz

80 SA_MAN

Cambrault
Zlotkey

80 SA_MAN
80 SA_MAN

Tucker
Bernstein
Hall
Olsen
Cambrault

LAST_NAME

80 SA_REP
80 SA_REP
80 SA_REP
80 SA_REP
80 SA_REP

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Tuvault

80 SA_REP

King

80 SA_REP

Sully

80 SA_REP

McEwen

80 SA_REP

Smith

80 SA_REP

Doran

80 SA_REP

Sewall

80 SA_REP

Vishney

80 SA_REP

Greene

80 SA_REP

Marvins

80 SA_REP

Lee

80 SA_REP

LAST_NAME

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Ande

80 SA_REP

Banda

80 SA_REP

Ozer

80 SA_REP

Bloom
Fox

80 SA_REP
80 SA_REP

Smith

80 SA_REP

Bates

80 SA_REP

Kumar
Abel
Hutton
Taylor

LAST_NAME

80 SA_REP
80 SA_REP
80 SA_REP
80 SA_REP

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Livingston

80 SA_REP

Johnson

80 SA_REP

Taylor

50 SH_CLERK

Fleaur

50 SH_CLERK

Sullivan

50 SH_CLERK

Geoni

50 SH_CLERK

Sarchand
Bull
Dellinger

50 SH_CLERK
50 SH_CLERK
50 SH_CLERK

Cabrio

50 SH_CLERK

Chung

50 SH_CLERK

LAST_NAME

DEPARTMENT_ID JOB_ID

------------------------- ------------- ----------

Dilly

50 SH_CLERK

Gates

50 SH_CLERK

Perkins

50 SH_CLERK

Bell
Everett
McCain

50 SH_CLERK
50 SH_CLERK
50 SH_CLERK

Jones

50 SH_CLERK

Walsh

50 SH_CLERK

Feeney

50 SH_CLERK

OConnell
Grant

LAST_NAME

50 SH_CLERK
50 SH_CLERK

DEPARTMENT_ID JOB_ID

------------------------- ------------- ---------Whalen

10 AD_ASST

Hartstein

20 MK_MAN

Fay
Mavris

20 MK_REP
40 HR_REP

Baer

70 PR_REP

Higgins

110 AC_MGR

Gietz

110 AC_ACCOUNT

106 rows selected.


Ans 39.
SQL> select w.last_name,w.salary from employees w where w.manager_id in (select

2 employee_id from employees where last_name='King');

LAST_NAME

SALARY

------------------------- ---------Kochhar

17000

De Haan

17000

Raphaely

11000

Weiss
Fripp

8000
8200

Kaufling

7900

Vollman

6500

Mourgos

5800

Russell

14000

Partners

13500

Errazuriz

12000

LAST_NAME

SALARY

------------------------- ---------Cambrault
Zlotkey
Hartstein

14 rows selected.

11000
10500
13000

And 40.
SQL> select department_id from employees minus (select department_id from employ
ees where job_id='ST_CLERK');

DEPARTMENT_ID
------------10
20
30
40
60
70
80
90
100
110

11 rows selected.

Ans 41.
SQL> select job_title from jobs intersect (select j.job_title from jobs j,depart
ments d,employees e where e.department_id=d.department_id and d.department_id in
(10,50,20));

JOB_TITLE
----------------------------------Accountant
Accounting Manager
Administration Assistant
Administration Vice President
Finance Manager
Human Resources Representative
Marketing Manager
Marketing Representative
President
Programmer
Public Accountant

JOB_TITLE
----------------------------------Public Relations Representative
Purchasing Clerk
Purchasing Manager
Sales Manager
Sales Representative
Shipping Clerk
Stock Clerk
Stock Manager

19 rows selected.

Ans 42.
SQL> create table newemployees(empid varchar2(200) primary key,ename varchar2(20
0) not null,address varchar2(500) not null,contact_no number(10) not null,email
varchar2(300));

Table created.

Ans 43.
SQL> insert into newemployees values('A101','Stuti Kumar','Kalyani Nagar',987654
3210,'stuti@abc.com');

1 row created.

SQL> insert into newemployees values('A102','Aishwarya rai','Yerwada',9988776655


,'aish@yahoo.com');

1 row created.

Ans 44.
SQL> update newemployees set ename='IBM Employee' where empid='A101';

1 row updated.

Ans 45.
SQL> delete newemployees;

2 rows deleted.

Ans 46.
SQL> rollback;

Rollback complete.

Ans 47.
SQL> truncate table newemployees;

Table truncated.

Ans 48.
SQL> alter table newemployees add (project varchar2(300));

Table altered.

Ans 49.
SQL> desc newemployees;
Name

Null?
Type
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------------------------------

EMPID
NOT N
ULL VARCHAR2(200)
ENAME
NOT N
ULL VARCHAR2(200)
ADDRESS

NOT N
ULL VARCHAR2(500)

CONTACT_NO

NOT N
ULL NUMBER(10)
EMAIL

VARCHAR2(300)
PROJECT

VARCHAR2(300)

Ans 50.

SQL> drop table newemployees;

Table dropped.

Ans 51.
SQL> create or replace view EMPLOYEES_VU as (select employee_id,last_name "EMPLO
YEE",department_id from employees);

View created.

Ans 52.
SQL> create or replace view DEPT50 as (select employee_id "EMPNO",last_name "EMP
LOYEE",department_id "DEPTNO" from employees where department_id=50) with check
option;

View created.

Ans 53.

SQL> select l.location_id,l.street_address,l.city,l.state_province,c.country_nam


e from loctions l,countries c where c.country_id=l.country_id;
Ans 54.
SQL> create index nameindex on departments(department_name);

Index created.

Ans 55.
SQL> select l.location_id,l.street_address,l.city,l.state_province,c.country_nam
e from locations l,countries c where l.country_id=c.country_id;

LOCATION_ID STREET_ADDRESS
STATE_PROVINCE

CITY

COUNTRY_NAME

----------- ---------------------------------------- ----------------------------- ------------------------- ---------------------------------------2200 12-98 Victoria Street


New South Wales

Australia

2800 Rua Frei Caneca 1360


Sao Paulo

Geneva

Switzerland

3000 Murtenstrasse 921


BE

Whitehorse

Canada

2900 20 Rue des Corps-Saints


Geneve

Toronto

Canada

1900 6092 Boxwood St


Yukon

Sao Paulo

Brazil

1800 147 Spadina Ave


Ontario

Sydney

Bern

Switzerland

2000 40-5-12 Laogianggen

Beijing

China
2700 Schwanthalerstr. 7031
Bavaria

Germany

Munich

2100 1298 Vileparle (E)


Maharashtra

Bombay

India

1000 1297 Via Cola di Rie

Roma

Italy
1100 93091 Calle della Testa

Venice

Italy

LOCATION_ID STREET_ADDRESS
STATE_PROVINCE

CITY

COUNTRY_NAME

----------- ---------------------------------------- ----------------------------- ------------------------- ---------------------------------------1200 2017 Shinjuku-ku


Tokyo Prefecture

Tokyo

Japan

1300 9450 Kamiya-cho

Hiroshima

Japan
3200 Mariano Escobedo 9991
Distrito Federal,

Mexico

3100 Pieter Breughelstraat 837


Utrecht

Mexico City

Utrecht

Netherlands

2300 198 Clementi North

Singapore

Singapore
2400 8204 Arthur St

London

United Kingdom
2500 Magdalen Centre, The Oxford Science Park Oxford
Oxford

United Kingdom

2600 9702 Chester Road


Manchester

United Kingdom

1400 2014 Jabberwocky Rd


Texas

Stretford

Southlake

United States of America

1500 2011 Interiors Blvd


California

United States of America

1600 2007 Zagora St


New Jersey

South San Francisco

South Brunswick

United States of America

LOCATION_ID STREET_ADDRESS
STATE_PROVINCE

CITY

COUNTRY_NAME

----------- ---------------------------------------- ----------------------------- ------------------------- ---------------------------------------1700 2004 Charade Rd


Washington

Seattle

United States of America

23 rows selected.

Ans 56.
SQL> select e.last_name,j.job_title,e.department_id,d.department_name from emplo
yees e,departments d,jobs j,locations l where e.department_id=d.department_id an
d e.job_id=j.job_id and d.location_id=l.location_id and l.city='Toronto';

LAST_NAME
RTMENT_NAME

JOB_TITLE

DEPARTMENT_ID DEPA

------------------------- ----------------------------------- ------------- ----------------------------Hartstein

Marketing Manager

20 Mark

Marketing Representative

20 Mark

eting
Fay
eting

You might also like