0% found this document useful (0 votes)
3K views

Solved Assignment

The document describes a CLUB table with columns for coach information like name, age, sport coached, date of appointment, pay, gender, and number of players. It then lists various SQL queries to retrieve, filter, group, and perform calculations on the data in the table.

Uploaded by

Chinmayi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

Solved Assignment

The document describes a CLUB table with columns for coach information like name, age, sport coached, date of appointment, pay, gender, and number of players. It then lists various SQL queries to retrieve, filter, group, and perform calculations on the data in the table.

Uploaded by

Chinmayi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

CLUB

C_Id CoachName Age Sports DateofApp Pay Gender 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
Q1. Create the above table AND DO THE FOLLOWING
(a) To show all information about the swimming coaches in the club.
SELECT * FROM CLUB WHERE SPORTS=”SWIMMING”;
(b) To show all information of the CLUB where coach name starts with “K”.
SELECT * FROM CLUB WHERE COACHNAME LIKE”K%”;
(c) To show the names of coaches in sorted order of the name.
SELECT COACHNAME FROM CLUB ORDER BY NAME;
(d) To list the names of all coaches with their date of appointment (DateofApp) in descending order.
SELECT COACHNAME FROM CLUB ORDER BY DATEOFAPP DESC;
(e) To display coach name, age and gender of Male members.
SELECT COACHNAME,AGE,GENDER FROM CLUB WHERE GENDER=”M”;
(f) To show all information of coaches whose age is more than 35 and are paid between 1500 and 2000.
SELECT * FROM CLUB WHERE AGE>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.
SELECT COACHNAME,PAY,AGE,0.05*PAY AS BONUS FROM CLUB;
(h) To show distinct names of the games available in club.
SELECT DISTINCT(SPORTS) FROM CLUB;
(i) To count the total number of coaches in the club
SELECT COUNT(COACHNAME) FROM CLUB;
(j) To count and display total coaches in each game
SELECT SPORTS,COUNT(COACHNAME) FROM CLUB GROUP BY SPORTS;
(k) To display Sports wise sum of pay from club table.
SELECT SPORTS,SUM(PAY) FROM CLUB GROUP BY SPORTS;
(l) To display highest age of coach, lowest pay of coach form table club.
SELECT MAX(AGE),MIN(PAY) FROM CLUB;
(m) Give the output of the following SQL command.
(i) Select COUNT( Distinct SPORTS) from CLUB;
COUNT( Distinct SPORTS)
4
(ii) Select MIN(Age) From CLUB Where gender = “F”;
MIN(Age)
34
(iii) Select AVG(Pay) From CLUB Where Sports = “KARATE”;
AVG(Pay)
1100
(iv) Select SUM(Pay) From CLUB Where DateofApp > “2008-01-31”;
SUM(Pay)
10300
(v) Select Sports From CLUB where Pay Between 700 and 1000 ;
SPORTS
KARATE
SWIMMING
SWIMMING
SWIMMING
(vi) Select Sports From CLUB where Pay IN ( 700, 1000,2000) ;
SPORTS
KARATE
SWIMMING
(vii) SELECT Sport, SUM(pay) FROM CLUB GROUP BY Sport Having gender=’M’ ;
Sport SUM(pay)
KARATE 2100
SQUASH 2000
BASKETBALL 3200
SWIMMING 1600
(n) To delete record of coaches whose salary is less than 1000
DELETE FROM CLUB WHERE PAY<1000;
(o) To delete record of coaches whose name ends with ‘N’ and has five characters
DELETE FROM CLUB WHERE COACHNAME LIKE “_ _ _ _N”;
(p) To increase the salary of all coaches by 20%
UPDATE CLUB SET PAY=PAY+(0.20*PAY);
Q2. 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

You might also like