0% found this document useful (0 votes)
35 views2 pages

Day 3

The document contains SQL queries for managing and retrieving data from two tables: 'school' and 'admin'. It includes operations such as updating periods for English teachers, displaying male teachers' details, counting teachers by subject, and filtering teachers based on experience and joining date. Additionally, it covers deletion of specific entries, displaying recent joiners, and aggregating experience by designation.

Uploaded by

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

Day 3

The document contains SQL queries for managing and retrieving data from two tables: 'school' and 'admin'. It includes operations such as updating periods for English teachers, displaying male teachers' details, counting teachers by subject, and filtering teachers based on experience and joining date. Additionally, it covers deletion of specific entries, displaying recent joiners, and aggregating experience by designation.

Uploaded by

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

table:school

code teachername subject doj periods exp


1001 ravishankar english 12/03/2000 24 10
1009 priya rai physics 03/09/1998 26 12
1203 lisa anand english 09/03/2000 27 5
1045 yashraj maths 24/08/2000 24 15
1123 gnan physics 16/07/1999 28 3
1167 harish chemistry 19/10/1999 27 5
1215 umesh physics 11/05/1998 22 16
code teachername subject doj periods exp
table:admin
code gender designation
1001 male viceprincipal
1009 female coordinator
1203 female coordinator
1045 male hod
1123 male senior teacher
1167 male senior teacher
1215 male hod

a. To decrease period by 10% of the teachers of English subject.


update school set periods=periods-periods*10/100 where
subject='English';

b. To display TEACHERNAME, CODE and DESIGNATION from tables


SCHOOL and ADMIN whose gender is male
ans)
select school.code,teachername,designation from school,admin
where school.code=admin.code and gender="male";

c. To Display number of teachers in each subject.

ans)
select count(*) from school
group by subject;
d. To display details of all teachers who have joined
the school after
01/01/1999 in descending order of experience.
ans)
select * from school where doj>"1999-01-01"
order by exp desc;
e. Delete all the entries of those teachers whose experience
is less than 10 years
and name contains the substring ‘IS’ in SCHOOL table.
ans)
delete * from student where exp<10 and teachername
like "%is%";

f. Display the name of the teacher who is joined recently.


select teachername from school where year(doj)=2000;

g. Display the minimum experience in Physics subject.


ans)
select min(exp)from school where subject='physics';

h. Display the number of Female teachers .


ans)
select count(*) from school,admin where school.code=
admin.code and gender='female";
select count(*) from admin where gender="female";

i. Display the Designation which has minimum 2 teachers.


designation => admin
ans)
select school.code,teachername,designation from school,
admin where school.code=admin.code;
ans)
select school.code,teachername,designation from school,
admin where school.code=admin.code limit 2;

j. Display all the details of HOD.


ans)
select school.code,teachername,subject,doj,periods,exp,
gender,designation from school,admin where
school.code=admin.code and designation='hod';

l. Display the Designation wise total experience.


ans)
select designation,exp from admin,school where
school.code=admin.code order by exp;

m. To list the names of all teachers with their date of joining


in descending
order.
ans)
select teachername,doj from school order by doj desc;

n. To display number of male and female teachers


in Coordinator Designation.
ans)
select count(*) from school,admin where school.code=
admin.code and designation='coordinator';

k. Display the designations of English subject.


select designation from admin,school
where school.code=admin.code and
subject='english';

o. Display the teacher details who are joined in the year 2000.

select * from school where year(doj) =2000;


or using joins
select school.code,teachername,,,,.......,gender,designation
from school,admin where school.code=admin.code
and year(doj)=2000;

You might also like