Sudharsanam Vidyaashram: Computer Science
Sudharsanam Vidyaashram: Computer Science
Sudharsanam Vidyaashram: Computer Science
VIDYAASHRAM
(CBSE Affiliation No.1930715)
ISO 9001:2015 Certified Institution
COMPUTER SCIENCE
CLASS 12TH SCIENCE (CBSE)
Submitted by :N.J.ELANGOVAN
Reg.No :
1
MY SQL QUERIES
GUIDED BY SUBMITTED BY
Mr. D. MUKESH KANNA N.J.ELANGOVAN
(PGT Computer Science) CLASS-XII SEC- C2
REGISTER NO-
YEAR - 2021-2022
SUDHARSANAM VIDYAASHRAM
VEERARAGHAVAPURAM
THIRUVALLUR
2
BONAFIDE CERTIFICATE
REGISTER NUMBER
year 2021-22.
3
1. Create a table worker45 with a following attributes:
ecode,name,design,plevel,doj,dob.
SQL> create table worker45(ecodeint,name char(15),design char(12),plevel char(4), dojdate,dob date);
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Table created.
4
4. Insert the values for the table paylevel45.
SQL> insert into paylevel45 values('p001',26000,12000);
1 row created.
1 row created.
1 row created.
5
6. Display all the tuples of the table paylevel45.
SQL> select*from paylevel45;
-------------- ----------
DESIGN
------------
clerk
mechanic
supervisor
operator
8. Display all the values of the attributes designation from the worker45.
SQL> select all design from worker45;
DESIGN
------------
supervisor
operator
operator
mechanic
6
clerk
NAME DESIGN
------------ ------------
fizza operator
10.To display the details of name and designation whose plevel is either p001
or p002.
SQL> select name,design from worker45 where plevel='p001' or plevel='p002';
NAME DESIGN
--------------- ------------
radheshyamsupervisor
chandernathoperator
11.To display the details of the name and designation whose plevel are p001
and p002.
SQL> select name,design from worker45 where plevel in('p001','p002');
NAME DESIGN
--------------- ------------
radheshyam supervisor
chandernath operator
7
12.To display the details ofthe name and designation whose plevel are not
p001 and p002.
SQL> select name,design from worker45 where plevel not in('p001','p002');
NAME DESIGN
--------------- ------------
fizzaoperator
ameenahmed mechanic
sanyaclerk
13. Display all details from paylevel45 whose allowances ranges from 5000 to
10000(inclusive of both values)
------------ ----------
14.Display all details from paylevel45 whose allowances ranges from 5000 to
10000(exclusive of both values)
SQL> select*from paylevel45 where allowance >5000 and allowance <10000;
8
15.Display all details from paylevel45 whose allowances not in the range from
5000 to 10000.
SQL> select*from paylevel45 where allowance not between 5000 and 10000;
16. Display all details from worker45 whose name starts with r.
11 Radheshyamsupervisor p00113-SEP-0423-AUG-81
17.Display all the details of worker45 whose name not starts with r.
SQL> select*from worker45 where name not like 'r%';
9
18. Display all the details of worker45 in descending order of designation.
SQL> select*from worker45 order by design desc;
19.To display the details of all worker45 in ascending order with name whose
ecode is more than 13
SQL> select*from worker45 where ecode>13 order by name;
10
20.Display the details of all workers in ascending order of name and
descending order of design.
SQL> select*from worker45 order by name asc,designdesc;
14 ameenahmedmechanic p00421-AUG-0613-MAR-84
21.Display the total amount of allowance from paylevel45 whose pay is more
than 15000.
SQL> select sum(allowance) from paylevel45 where pay>15000;
SUM(ALLOWANCE)
--------------
22000
11
22.Display the number of records present in the table worker45 and
paylevel45
SQL> select count(*) from worker45;
COUNT(*)
----------
COUNT(*)
----------
23.Display the maximum and the minimum pay of the worker45 in paylevel.
SQL> select max(pay),min(pay) from paylevel45;
MAX(PAY) MIN(PAY)
------------------------
26000 12000
AVG(ALLOWANCE)
--------------------------
9333.3333
12
25. Display the number of designation of the worker that belongs to different
plevel.
SQL> select count(distinct design) from worker45;
COUNT(DISTINCTDESIGN)
--------------------------------------
COUNT(ALLNAME)
--------------------------
27. Display the number of plevel of each worker from each designation.
SQL> select count(plevel),plevel from worker45 group by plevel;
COUNT(PLEVEL) PLEV
----------------------- -----
1 p004
1 p001
1 p002
1 p005
1 p003
13
28. Display the number of designation of each worker whose count is more
than 1.
SQL> select count(design),design from worker45 group by design having count(design)>1;
COUNT(DESIGN)DESIGN
----------------------- ------------
2 operator
PLEVPAY+ALLOWANCE
------- --------------------------
p001 38000
p002 32000
p003 18000
PLEVPAY+ALLOWANCE '
---- --------------------------
p001 38000 $
p002 32000 $
p003 18000 $
14
31. Create a table workerinfofrom table worker with the attributesdoj,dob
and name .
SQL> create table workerinfo AS (select name, doj, dob from worker45 where name =
chandernath)
chandernath22-FEB-8112-JUL-87
Table altered.
table modified.
15
34.Insert the values for the column experience and display the table worker45.
SQL> update worker45 set experience=10 where ecode=11;
1 row updated.
1 row updated.
1 row updated.
1 row updated.
1 row updated.
16
35.To display the name and pay of your worker45 whose ecode is less than 13.
SQL> selectname,pay from worker45 w,paylevel45 p where w.plevel=p.plevel and w.ecode<13;
NAME PAY
--------------- ----------
radheshyam26000
chandernath 22000
125*43
----------
5375
LOWER('
------------
Welcome
UPPER(
----------
THANKS
17
39.Delete the values of the table workerinfo whose names starts with c.
SQL> delete from workerinfo where name like 'c%';
1 row deleted.
Table dropped.
18