Vel'S Public School, Sankarankovil Informatics Practices (065) Worksheet-2 Unit-2: Database Query Using SQL
Vel'S Public School, Sankarankovil Informatics Practices (065) Worksheet-2 Unit-2: Database Query Using SQL
Vel'S Public School, Sankarankovil Informatics Practices (065) Worksheet-2 Unit-2: Database Query Using SQL
(a) To show all information of students where capacity is more than the no of student in order of
rtno.
(b) To show area_covered for buses more than 20 km., but charges less than 80000.
(c) To show the area covered by Bhalla Co. and kisan tours
(d) To show the names of all the transporters without repeating their names.
(e) To show all the bus routes number where the distance is less than 30.
(f) To show the area whose names end with „r‟ in decreasing order of the area covered.
(g) To show rtno, area_covered and average cost per student for all routes where average cost per
student is - charges/noofstudents
(h)To show the number of areas covered by all the bus routes
(i) To show the number of area covered by each transporter.
(j) To show the maximum capacity of a bus
(k) To show transporter wise total number of students traveling.
(l) Add new record with data: (11, “ Moti bagh”,35,32,10,” kisan tours “, 35000)
(m) Give the output considering the original relation as given :
(n)select sum(distance) from schoolbus where transporter= “ Yadav Co.”;
(o) select min (noofstudents) from schoolbus;
(p)select avg(charges) from schoolbus where transporter= “Anand travels”;
(q) select distinct transporter from schoolbus ;
(r) select count(distinct transporter) from schoolbus ;
(s) select count(*) from schoolbus ;
(t) select transporter, count(*) from schoolbus group by transporter ;
(u)select transporter, max(charges) from schoolbus group by transporter ;
Table: CLUB
C_Id CoachName Age Sports DateofApp Pay Sex No_Players
1 KUKREJA 35 KARATE 2012-03-27 1000 M 20
2 RAVINA 34 KARATE 2008-01-20 1200 F 15
3 KARAN 34 SQUASH 2009-02-19 2000 M 2
4 TARUN 33 BASKETBALL 2012-01-01 1500 M 16
5 ZUBIN 36 SWIMMING 2008-01-12 700 M 10
6 KETAKI 36 SWIMMING 2012-02-24 800 F 10
7 ANKITA 39 SQUASH 2013-02-20 2200 F 5
8 ZAREEN 37 KARATE 2010-02-22 1100 M 18
9 KUSH 41 SWIMMING 2008-01-13 900 M 17
10 SHAILYA 37 BASKETBALL 2008-02-19 1700 M 17
2. Q2. Create the above table AND DO THE FOLLOWING
(a) To show all information about the swimming coaches in the club.
(b) To show all information of the CLUB which coach name start with “K”.
(c) To show the names of coaches in sorted order of the name.
(d) To list the names of all coaches with their date of appointment (DateofApp) in descending order.
(e) To display coach name, age and sex from CLUB which sex is Male (M).
(f) To show all information which age more than 35 and Pay between 1500 and 2000.
(g) To display a report, showing coach name, pay, age and bonus (15% of Pay) for all the coaches.
(h) To show distinct names of the games available in club.
(i) To count the total number of coaches in the club
(j) To count and display total coaches in each game
(k) To display Sports wise sum of pay from club table.
(l) To display highest age of coach, lowest pay of coach form table club.
(m)Give the output of the following SQL command.
(i) Select COUNT( Distinct SPORTS) from CLUB;
(ii)Select MIN(Age) From CLUB Where Sex = “F”;
(iii) Select AVG(Pay) From CLUB Where Sports = “KARATE”;
(iv) Select SUM(Pay) From CLUB Where DateofApp > “2008-01-31”;
(v) Select Sports From CLUB where Pay Between 700 and 1000 ;
(vi) Select Sports From CLUB where Pay IN ( 700, 1000,2000) ;
(vii) SELECT Sport, SUM(pay) FROM CLUB GROUP BY Sport Having Sex=‟M‟ ;
(o) To delete record of coaches whose salary is less than 1000
(p) To delete record of coaches whose name ends with „N‟ and has five characters
(q) To increase the salary of all coaches by 20%
Q3. Consider the table student given below. Find out the output of
the following queries: Rno Fees
A) SELECT COUNT(*) FROM STUDENT; 1 4000
B) SELECT COUNT(FEES) FROM STUDENT; 2 4300
C) SELECT AVG(FEES) FROM STUDENT; 3 5000
D) SELECT FEES + 100 FROM STUDENT ; 4 Null
Q.4
Q.5
Q.6
Q.7
Q8.
i. Display flight codes, starting place, destination, number of flights in descending order of number
of flights.
ii. Count and display number of flights starting from each city(START).
iii. Count and display number of flights starting from each city(START) where number of stops more
than 2.
iv. Display flight data in ascending order of no of stops
5. v. Count and display number of flights reaching at each destination.
vi. Count and display number of flights without stops
Q9.
Write SQL queries w/r to store table data
Q10.