Database Name : sqlpractice
Table Name : Student
| Roll | Sname | Gender | Dob | Total | Average | Grade |
| ---- | ------- | ------ | ---------- | ----- | ------- | ----- |
| 1 | Anand | M | 05/13/2001 | 407 | 81.4 | B |
| 2 | Ajay | M | 04/02/2001 | 400 | 80 | C |
| 3 | Bharath | M | 11/05/2000 | 355 | 71 | D |
| 4 | Shivani | F | 05/06/2001 | 476 | 95.2 | A |
| 5 | Sarchin | M | 12/23/2001 | 400 | 80 | C |
| 6 | Dhoni | M | 11/17/2000 | 415 | 83 | B |
| 7 | Kamala | F | 12/05/2001 | 400 | 80 | C |
| 8 | Varun | M | 11/11/2000 | 470 | 94 | A |
| 9 | Rekha | F | 10/15/2000 | 490 | 98 | A |
| Roll | Parent | Address | Phone_No |
| ---- | ------ | ---------------- | -------- |
| 2 | ABC | 1st Cross Street | 12345678 |
| 3 | XYZ | 2nd Cross Street | 41234561 |
| 4 | PQR | 3rd Cross Street | 12370171 |
| 7 | LMN | 4th Cross Street | 40007714 |
| 9 | ABCD | 5th Cross Street | 56789101 |
Answer
Query
SELECT Sname, Gender
FROM Student;
Output
+---------+--------+
| Sname | Gender |
+---------+--------+
| Anand | M |
| Ajay | M |
| Bharath | M |
| Shivani | F |
| Sarchin | M |
| Dhoni | M |
| Kamala | F |
| Varun | M |
| Rekha | F |
+---------+--------+
Answer
Query
SELECT * FROM Student;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 400 | 80.00 | C |
| 6 | Dhoni | M | 2001-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-11 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
SELECT distinct Total FROM Student;
Output
+-------+
| Total |
+-------+
| 407 |
| 355 |
| 476 |
| 400 |
| 415 |
| 470 |
| 490 |
+-------+
Answer
Query
SELECT Roll,Sname FROM Student WHERE Gender='M';
Output
+------+---------+
| Roll | Sname |
+------+---------+
| 1 | Anand |
| 2 | Ajay |
| 3 | Bharath |
| 5 | Sarchin |
| 6 | Dhoni |
| 8 | Varun |
+------+---------+
Answer
Query
SELECT Roll,Sname FROM Student WHERE Total>400 AND Gender='M';
Output
+------+-------+
| Roll | Sname |
+------+-------+
| 1 | Anand |
| 6 | Dhoni |
| 8 | Varun |
+------+-------+
Answer
Query
SELECT * FROM Student WHERE Total BETWEEN >=400 AND <=450
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 5 | Sarchin | M | 2001-12-23 | 400 | 80.00 | C |
| 6 | Dhoni | M | 2001-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
SELECT * FROM Student WHERE Gender='M' AND Total BETWEEN >=400 AND <=450
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-02-04 | 400 | 80.00 | C |
| 5 | Sarchin | M | 2001-12-23 | 400 | 80.00 | C |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
SELECT Sname FROM Student WHERE Grade='A' OR Grade='B' OR Grade='C';
Output
+---------+
| Sname |
+---------+
| Anand |
| Ajay |
| Shivani |
| Sarchin |
| Dhoni |
| Kamala |
| Varun |
| Rekha |
+---------+
Answer
Query
SELECT Sname FROM Student WHERE Gender='F' AND Grade='A' OR Gender='F' AND Grade='B';
Output
+---------+
| Sname |
+---------+
| Shivani |
| Rekha |
+---------+
Answer
Query
SELECT Roll FROM Student WHERE NOT Grade='A' AND NOT Grade='B';
Output
+------+
| Roll |
+------+
| 2 |
| 3 |
| 5 |
| 7 |
+------+
Answer
Query
SELECT Sname FROM Student WHERE YEAR(Dob)='2001';
Output
+---------+
| Sname |
+---------+
| Anand |
| Ajay |
| Shivani |
| Sarchin |
| Kamala |
+---------+
Answer
Query
SELECT Sname FROM Student WHERE MONTH(Dob)='11' AND YEAR(Dob)='2000';
Output
+---------+
| Sname |
+---------+
| Bharath |
| Dhoni |
| Varun |
+---------+
Answer
Query
SELECT Sname FROM Student WHERE NOT MONTH(Dob)='11' AND YEAR(Dob)='2000';
Output
+-------+
| Sname |
+-------+
| Rekha |
+-------+
Answer
Query
SELECT distinct Grade FROM Student;
Output
+-------+
| Grade |
+-------+
| B |
| C |
| D |
| A |
+-------+
Shivani has scored an average of 95.2 with grade A.
Answer
Query
SELECT concat(Sname, ' has scored an average of ', Average, ' with grade ', Grade,'.') as Female Details FROM Student WHERE Gender='F';
Output
+------------------------------------------------------+
| Female Details |
+------------------------------------------------------+
| Shivani has scored an average of 95.20 with grade A. |
| Kamala has scored an average of 80.00 with grade C. |
| Rekha has scored an average of 98.00 with grade A. |
+------------------------------------------------------+
Q16. Assume there is no average column in the table and the Total attribute is the expression of 5 subjects mark. Display the name and average marks of all the female students.
Answer
Query
SELECT Sname , Total/5 AS Avg FROM Student WHERE Gender='F'
Output
+---------+---------+
| Sname | Avg |
+---------+---------+
| Shivani | 95.2000 |
| Kamala | 80.0000 |
| Rekha | 98.0000 |
+---------+---------+
Answer
Query
SELECT Sname FROM Student WHERE Sname LIKE 'A%';
Output
+-------+
| Sname |
+-------+
| Anand |
| Ajay |
+-------+
Answer
Query
SELECT Sname FROM Student WHERE Sname LIKE ('A%') and ENAME LIKE('%d');
Output
+------+-------+-------+
| Roll | Sname | Total |
+------+-------+-------+
| 1 | Anand | 407 |
+------+-------+-------+
Answer
Query
SELECT * FROM Student WHERE Sname LENGTH(Sname)='5';
Output
+------+-------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+-------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 8 | Varun | M | 2000-11-11 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+-------+--------+------------+-------+---------+-------+
Answer
Query
SELECT * FROM Student WHERE Sname LIKE '%i%';
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 400 | 80.00 | C |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
SELECT Sname FROM Student WHERE Sname NOT LIKE ('A%') and Sname NOT LIKE('S%');
Output
+---------+
| Sname |
+---------+
| Bharath |
| Dhoni |
| Kamala |
| Varun |
| Rekha |
+---------+
Answer
Query
SELECT Sname FROM Student WHERE DAY(Dob)='05';
Output
+---------+
| Sname |
+---------+
| Bharath |
| Kamala |
+---------+
Answer
Query
SELECT Sname FROM Student ORDER BY Sname ASC;
Output
+---------+
| Sname |
+---------+
| Ajay |
| Anand |
| Bharath |
| Dhoni |
| Kamala |
| Rekha |
| Sarchin |
| Shivani |
| Varun |
+---------+
Answer
Query
SELECT Sname,Total FROM Student WHERE Gender='F' ORDER BY Total DESC ;
Output
+---------+-------+
| Sname | Total |
+---------+-------+
| Rekha | 490 |
| Shivani | 476 |
| Kamala | 400 |
+---------+-------+
Q25. Display the name, grade and total of all the students who have scored above 395 in descending order of their grades and ascending order of their name.
Answer
Query
SELECT Sname,Grade,Total FROM Student WHERE Total>395 ORDER BY Grade DESC,Sname ASC;
Output
+---------+-------+-------+
| Sname | Grade | Total |
+---------+-------+-------+
| Ajay | C | 400 |
| Kamala | C | 400 |
| Sarchin | C | 400 |
| Anand | B | 407 |
| Dhoni | B | 415 |
| Rekha | A | 490 |
| Shivani | A | 476 |
| Varun | A | 470 |
+---------+-------+-------+
Answer
Query
SELECT SUM(Total) FROM Student WHERE Grade='A';
Output
+------------+
| SUM(Total) |
+------------+
| 1436 |
+------------+
Answer
Query
SELECT AVG(Average) FROM Student WHERE Grade='A';
Output
+------------+
|AVG(Average)|
+------------+
| 95.673333 |
+------------+
Answer
Query
SELECT COUNT(Roll) FROM Student;
Output
+--------------+
| COUNT(Roll) |
+--------------+
| 9 |
+--------------+
Answer
Query
SELECT COUNT(distinct Grade) FROM Student;
Output
+------------------------+
| COUNT(distinct(Grade)) |
+------------------------+
| 4 |
+------------------------+
Answer
Query
SELECT * FROM Student WHERE Dob in (SELECT MAX(Dob) FROM Student);
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 5 | Sarchin | M | 2001-12-23 | 400 | 80.00 | C |
+------+---------+--------+------------+-------+---------+-------+
Answer
Qurey
SELECT MAX(Dob), MIN(Dob), SUM(Total)
FROM Student
WHERE Dob BETWEEN '2001-01-01' AND '2001-12-31';
Output
+------------+------------+------------+
| MAX(Dob) | MIN(Dob) | SUM(Total) |
+------------+------------+------------+
| 2001-12-23 | 2001-04-02 | 2083 |
+------------+------------+------------+
Qurey
SELECT COUNT(*), MAX(Total), MIN(Total)
FROM Student
WHERE Grade IN ('A','B');
Output
+----------+------------+------------+
| COUNT(*) | MAX(Total) | MIN(Total) |
+----------+------------+------------+
| 5 | 490 | 407 |
+----------+------------+------------+
Query
SELECT SUM(Total + 5)
FROM Student
WHERE Grade='D';
Output
+----------------+
| SUM(Total + 5) |
+----------------+
| 360 |
+----------------+
Qurey
SELECT AVG(Total / 5)
FROM Student;
Output
+----------------+
| AVG(Total / 5) |
+----------------+
| 84.73333333 |
+----------------+
Answer
Query
SELECT Gender,COUNT(Gender) FROM Student GROUP BY Gender;
Output
+--------+---------------+
| Gender | count(Gender) |
+--------+---------------+
| F | 3 |
| M | 6 |
+--------+---------------+
Answer
Query
SELECT MAX(Total), MIN(Total),Grade FROM Student GROUP BY Grade;
Output
+------------+------------+-------+
| MAX(Total) | MIN(Total) | Grade |
+------------+------------+-------+
| 490 | 470 | A |
| 415 | 407 | B |
| 400 | 400 | C |
| 355 | 355 | D |
+------------+------------+-------+
Q34. Display the maximum and minimum total of the students born in the year 2001 based on their grade.
Answer
Query
SELECT MAX(Total), MIN(Total),Grade FROM Student WHERE year(Dob)='2001' GROUP BY Grade;
Output
+------------+------------+-------+
| MAX(Total) | MIN(Total) | Grade |
+------------+------------+-------+
| 476 | 470 | A |
| 415 | 407 | B |
| 400 | 400 | C |
+------------+------------+-------+
Answer
Query
SELECT COUNT(Grade),Grade FROM Student WHERE Grade='A' OR Grade='B' GROUP BY Grade;
Output
+--------------+-------+
| COUNT(Grade) | Grade |
+--------------+-------+
| 3 | A |
| 2 | B |
+--------------+-------+
Q36. Display the number of students grade wise where number of students in each grade is more than two.
Answer
Query
SELECT COUNT(Grade),Grade FROM Student GROUP BY Grade HAVING COUNT(Grade)>2;
Output
+--------------+-------+
| COUNT(Grade) | Grade |
+--------------+-------+
| 3 | A |
| 3 | C |
+--------------+-------+
Answer
Query
UPDATE STUDENT SET Dob='2000-11-12' WHERE Sname='Varun';
SELECT * FROM Student;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-02-04 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-05-11 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-06-05 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | C |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-05-12 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
UPDATE Student SET Total=Total+10,Grade='B' WHERE Sname='Sarchin';
SELECT * FROM Student;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-02-04 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-05-11 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-06-05 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-05-12 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
CREATE view v1 as SELECT * FROM student;
SELECT * FROM v1;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
CREATE view v2 as SELECT Roll,Sname FROM Student WHERE Grade='A';
Output
Query OK, 0 rows affected
Answer
Query
SELECT * FROM v2;
Output
+------+---------+
| Roll | Sname |
+------+---------+
| 4 | Shivani |
| 8 | Varun |
| 9 | Rekha |
+------+---------+
Q42. Create a view V3 that has a a copy of roll number and name of all the 'A' graders but with new column names. Display the view after creation.
Answer
Query
CREATE view v3 as SELECT Roll as RollNo., Sname as StuName FROM Student WHERE Grade='A';
SELECT * FROM v3;
Output
+---------+---------+
| RollNo. |StuName |
+---------+---------+
| 4 | Shivani |
| 8 | Varun |
| 9 | Rekha |
+---------+---------+
Answer
Query
ALTER table Student ADD Age int;
Output
+------+---------+--------+------------+-------+---------+-------+------+
| Roll | Sname | Gender | Dob | Total | Average | Grade | Age |
+------+---------+--------+------------+-------+---------+-------+------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B | NULL |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C | NULL |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D | NULL |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A | NULL |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B | NULL |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B | NULL |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C | NULL |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A | NULL |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A | NULL |
+------+---------+--------+------------+-------+---------+-------+------+
Query
UPDATE Student SET Age = Truncate(DATEDIFF(CURRENT_DATE,Dob)/365,0);
Output
+------+---------+--------+------------+-------+---------+-------+------+
| Roll | Sname | Gender | Dob | Total | Average | Grade | Age |
+------+---------+--------+------------+-------+---------+-------+------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B | 19 |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C | 19 |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D | 20 |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A | 19 |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B | 19 |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B | 20 |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C | 19 |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A | 20 |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A | 20 |
+------+---------+--------+------------+-------+---------+-------+------+
Answer
Query
ALTER table Student DROP Age;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
DESC Student;
Output
+---------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------+------+-----+---------+-------+
| Roll | int(11) | NO | | NULL | |
| Sname | char(15) | YES | | NULL | |
| Gender | char(2) | YES | | NULL | |
| Dob | date | YES | | NULL | |
| Total | int(11) | YES | | NULL | |
| Average | decimal(10,2) | YES | | NULL | |
| Grade | char(2) | YES | | NULL | |
+---------+---------------+------+-----+---------+-------+
Query
SELECT * FROM Student;
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Query
ALTER table Student MODIFY column Average FLOAT(10,2);
Query
DESC Student;
Output
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| Roll | int(11) | NO | | NULL | |
| Sname | char(15) | YES | | NULL | |
| Gender | char(2) | YES | | NULL | |
| Dob | date | YES | | NULL | |
| Total | int(11) | YES | | NULL | |
| Average | float(10,2) | YES | | NULL | |
| Grade | char(2) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
Query
SELECT * FROM Student
Output
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 3 | Bharath | M | 2000-11-05 | 355 | 71.00 | D |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
SELECT Total/5 as AMF FROM Student WHERE Gender='F';
Output
+----------+
| AMF |
+----------+
| 95.2000 |
| 80.0000 |
| 98.0000 |
+----------+
Answer
Query
SELECT Student.Sname, Personal.Parent, Personal.Address FROM Student INNER JOIN Personal WHERE Student.Roll = Personal.Roll;
Output
+---------+--------+------------------+
| Sname | Parent | Address |
+---------+--------+------------------+
| Ajay | ABC | 1st Cross Street |
| Bharath | XYZ | 2nd Cross Street |
| Shivani | PQR | 3rd Cross Street |
| Kamala | LMN | 4th Cross Street |
| Rekha | ABCD | 5th Cross Street |
+---------+--------+------------------+
Answer
Query
SELECT Student.Roll,Student.Sname, Personal.Parent FROM Student INNER JOIN Personal on Student.Roll = Personal.Roll WHERE Grade='A';
Output
+------+---------+--------+
| Roll | Sname | Parent |
+------+---------+--------+
| 4 | Shivani | PQR |
| 9 | Rekha | ABCD |
+------+---------+--------+
Answer
Query
DELETE FROM Student WHERE Grade='D' SELECT * FROM Student;
Output
Query OK, 1 row affected
+------+---------+--------+------------+-------+---------+-------+
| Roll | Sname | Gender | Dob | Total | Average | Grade |
+------+---------+--------+------------+-------+---------+-------+
| 1 | Anand | M | 2001-05-13 | 407 | 81.40 | B |
| 2 | Ajay | M | 2001-04-02 | 400 | 80.00 | C |
| 4 | Shivani | F | 2001-05-06 | 476 | 95.20 | A |
| 5 | Sarchin | M | 2001-12-23 | 410 | 80.00 | B |
| 6 | Dhoni | M | 2000-11-17 | 415 | 83.00 | B |
| 7 | Kamala | F | 2001-12-05 | 400 | 80.00 | C |
| 8 | Varun | M | 2000-11-12 | 470 | 94.00 | A |
| 9 | Rekha | F | 2000-10-15 | 490 | 98.00 | A |
+------+---------+--------+------------+-------+---------+-------+
Answer
Query
DROP table Student;
Output
Table 'sqlpractice.student' doesn't exist