SQL FUNCTIONS
ASSIGNMENTS
Q.1
a. Give the output of following queries based on schoolbus table:
(i) select sum(distance) from schoolbus where transporter= “Yadav
travels”;
(ii) select min(noofstudents) from schoolbus;
(iii) select avg(charges) from schoolbus where transporter= “Anand
travels”;
(iv) select distinct transporter from schoolbus;
b. Write sql query for following
(i) Display area_covered in uppercase along with distance
(ii) Display area_covered with largest length(number of characters)
(iii) Display area_covered with largest distance
(iv) Display the list of schoolbus where rightmost part of transporter
is travels
(v) Display the total distance covered by ‘Anand travels’
(vi)Display the transporter which charges maximum with regards to
all area covered taken together.
Q.2
a. Give the output of following sql statement based on table
GRADUATE:
(i) Select MIN(AVERAGE) from GRADUATE where
SUBJECT=‖PHYSICS‖;
(ii) Select SUM(STIPEND) from GRADUATE WHERE div=2;
(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
(iv) Select COUNT(distinct SUBDJECT) from GRADUATE;
b. Write sql query for following
(i) Display the name of the students in lower case
(ii) Display the average stipend of COMP.SC. subject
(iii) Display the name , stipend of student where subject is either
physics or maths
(iv) Display the subject with maximum stipend
(v) Display the subject with maximum stipend(sum of stipend of all
student for each subject)
3.
a. Give the output of the following SQL statements.
i. Select COUNT(distinct department) from TEACHER;
ii. Select MAX(Age) from TEACHER where SEX=‘F‘;
iii. Select AVG(Salary) from TEACHER where SEX=‘M‘;
iv. Select SUM(Salary) from TEACHER where
DATOFJOIN<{12/07/96};
b. Write SQL query for following
i. Display the teacher name with maximum age
ii. Display the teacher name with minimum salary
iii. Display the department where maximum salary is being
given
iv. Display the name of the teacher where year of dateofadm
is 98
v. Display the name of the teacher whose day of dateofadm is
Monday
vi. Display how many males and females are there in teacher
table
4.
a. Give the output of following statement.
(i) Select COUNT(distinct company) from PRODUCT.
(ii) Select MAX(price)from PRODUCT where WARRANTY<=3
(iii) select avg(price) from PRODUCT
(IV) SELECT MAX(STOCK),PNAME FROM PRODUCT
b. Write SQL query for following
i. Display the product with oldest manufacturing date
ii. Display the product with maximum warranty
iii. Display the recent product
iv. Display the costliest TV company
v. Display manufacturing year of all products
vi. Display the product manufactured in MAR month
vii. display the product name with maximum length.