MySQL Query Questions
MySQL Query Questions
Table: COACHES
COACH_ID COACHNAM AGE SPORTS DATEOFAPP PAY SEX
E
1 KUKREJA 35 KARATE 1996-03-27 1000 M
1.1. List names of all coaches with their date of appointment (DATEOFAPP) in descending order.
1.2. Show all information about swimming coaches in the club.
1.3. The pay of Zubin was raised to 1000, update in table.
1.4. Show the number of coaches whose age is more than 35.
ANSWERS
TABLE CREATION
CREATE TABLE IF NOT EXISTS `coaches` (
DATA INSERTION
INSERT INTO `coaches` (`COACH_ID`, `COACHNAME`, `AGE`, `SPORTS`, `DATEOFAPP`,
`PAY`, `SEX`) VALUES
QUESTION 2:
Table: STUDENT
SNO NAME STIPEND STREAM AVGMARK GRADE CLASS
1 KARAN 400 MEDICAL 78.5 B 12B
ANSWERS
2.1. SELECT NAME FROM STUDENT WHERE CLASS LIKE '12%';
2.2. SELECT AVG(STIPEND) FROM STUDENT GROUP BY STREAM;
2.3. UPDATE STUDENT SET STIPEND = STIPEND + 50 WHERE STREAM LIKE 'NONMEDICAL';
2.4. SELECT DISTINCT STREAM FROM STUDENT;
TABLE CREATION
CREATE TABLE IF NOT EXISTS `student` (
DATA INSERTION
INSERT INTO `student` (`SNO`, `NAME`, `STIPEND`, `STREAM`, `AVGMARK`, `GRADE`,
`CLASS`) VALUES
QUESTION 3:
Table: TEACHERS
TNO NAME AGE DEPARTMENT DATEOFJOIN SALAR SEX
Y
1 JUGAL 34 COMPUTER 1997-01-10 12000 M
2 SHARMILA 31 HISTORY 1998-03-24 20000 F
3 SANDEEP 32 MATHEMATICS 1996-12-12 30000 M
4 SANGEETA 35 HISTORY 1999-07-01 40000 F
5 RAKESH 42 MATHEMATICS 1997-09-15 25000 M
6 SHYAM 50 HISTORY 1998-06-27 30000 M
7 SHIV 44 COMPUTER 1997-02-25 21000 M
8 SHALAKHA 33 MATHEMATICS 1997-07-31 20000 F
9 JYOTI 41 COMPUTER 1999-01-13 27000 F
10 SUNIL 37 HISTORY 1998-02-19 32000 M
ANSWERS
TABLE CREATION
CREATE TABLE IF NOT EXISTS `teachers` (
DATA INSERTION
INSERT INTO `teachers` (`TNO`, `NAME`, `AGE`, `DEPARTMENT`, `DATEOFJOIN`, `SALARY`,
`SEX`) VALUES
4.1. Show all data of all students whose name starts with ‘S’.
4.2. Show average marks class wise.
4.3. Show names of students sorted by marks.
4.4. Insert a new column in table for telephone number (TELENO).
ANSWERS
TABLE CREATION
CREATE TABLE IF NOT EXISTS `student1` (
DATA INSERTION
INSERT INTO `student1` (`ROLLNO`, `NAME`, `CLASS`, `DOB`, `GENDER`, `CITY`,
`MARKS`) VALUES
QUESTION 5:
Table: EMPLOYEE
ENO NAME DOB NATIVE SALARY DEPT HOBBY
121 SUMIT 1976-10-17 BENGALURU 7000 FINANCE GARDENING
5.1. Show the total salary given to the employee by the company.
5.2. Find number of employees whose hobby is sports.
5.3. Show native places of the employees without repetition.
5.4. Increase salary of employees who are in finance department by 10%.
ANSWERS
TABLE CREATION
CREATE TABLE IF NOT EXISTS `coaches` (
DATA INSERTION
INSERT INTO `coaches` (`COACH_ID`, `COACHNAME`, `AGE`, `SPORTS`, `DATEOFAPP`,
`PAY`, `SEX`) VALUES