You are on page 1of 3

STRUCTURED QUERY LANGUAGE(SQL)

SQL Practical

Write the SQL commands for (1) to (10) and write the output for (11) to (15), On the basis of table
EMPLOYEE.

ECODE ENAME ESEX EJOB EGRADE ESALARY ECITY


101 Jacob M President E1 5000 Bangalore
102 Anil M Manager E2 4000 Hyderabad
103 Mauhar M Manager E2 4000 Dholpur
104 Sangle M Manager E2 4000 Mumbai
105 Rajnikanth M Clerk E3 2000 Ahmedabad
106 Deepak M Clerk E3 2000 Delhi

(1).To create table with the mentioned attribute names with primary key constraints on ECODE.
(2).To display details of all Employees from the table EMPLOYEE.
(3).To display ECODE, ENAME and SALARY from the table EMPLOYEE.
(4).To display all Employees from the city ‘Delhi’.
(5).To display employees’ details having grades ‘E2’ or ‘E3’ from table EMPLOYEE.
(6).To display list of Employees having salary more than 2500 in the alphabetical order.
(7).To display number of Employee in each JOB.
(8).To insert new set of values into the table EMPLOYEE for all attributes.
(9).To double the salary of employee of grade ‘E3’;
(10). To delete the definition of table EMPLOYEE from Database.

(11). Select Count (DISTINCT ENAME) from EMPLOYEE;

(12). Select * from EMPLOYEE


where EGRADE=’E2’;

(13). Update EMPLOYEE


SET ESALARY = ESALARY+1000
Where ESALARY<2500;

(14). Select MIN (ESALARY) from EMPLOYEE

(15). Select EJOB, count (*) from EMPLOYEE


GROUP BY EJOB;
Ans. (1). create table EMPLOYEE
{ ECODE integer not null Primary Key,
ENAME varchar2 (10),
ESEX char(1),
EJOB varchar2 (10),
EGRADE char(2),
ESALARY decimal,
ECITY varchar2 (10)
};

Ans. (2) Select * from EMPLOYEE;

Ans.(3). Select ECODE, ENAME, ESALARY from EMPLOYEE;

Ans.(4). Select * from EMPLOYEE


Where ECITY = ‘Delhi’;

A-ns.(5). Select * from EMPLOYEE


Where ( EGRADE = ‘E1’ or EGRADE = ‘E2’ );

Ans.(6). Select * from EMPLOYEE


Where ESALARY > 2500
ORDER BY ENAME;

Ans.(7). Select EJOB, count(*)


From EMPLOYEE
GROUP BY EJOB;

Ans.(8). Insert into EMPLOYEE


values (107,’Jeet’,’M’, ’President’, ’E1’, 5000, ‘Delhi’);

Ans.(9). Update EMPLOYEE


SET ESALARY = ESALARY * 2
Where EGRADE = ‘E3’;

Ans.(10). Drop table EMPLOYEE;

Ans.(11). 6

Ans.(12).
ECODE ENAME ESEX EJOB EGRADE ESALARY ECITY
102 Anil M Manager E2 4000 Hyderabad
103 Mauhar M Manager E2 4000 Dholpur
104 Sangle M Manager E2 4000 Mumbai
Ans.(13).
ECODE ENAME ESEX EJOB EGRADE ESALARY ECITY
101 Jacob M President E1 5000 Bangalore
102 Anil M Manager E2 4000 Hyderabad
103 Mauhar M Manager E2 4000 Dholpur
104 Sangle M Manager E2 4000 Mumbai
105 Rajnikanth M Clerk E3 3000 Ahmedabad
106 Deepak M Clerk E3 3000 Delhi

Ans.(14). 2000

Ans.(15).
EJOB COUNT
President 1
Manager 3
Clerk 2

You might also like