Informatics Practices

Consider the following table named "Student":

RollNoNameMarksGradeFeesStream
1Mishra30C6000Commerce
2Gupta48B15000Arts
3Khan66A4800Science
4Chaddha24C12500Commerce
5Yadav23A10000Arts

Write the SQL functions which will perform the following operations:

(i) To show the sum of fees of all students.

(ii) To display maximum and minimum marks.

(iii) To count different types of grades available.

(iv) Write a query to count grade-wise total number of students.

SQL Queries

2 Likes

Answer

(i)

SELECT SUM(Fees) AS Total_Fees 
FROM Student;
Output
+------------+
| Total_Fees |
+------------+
|      48300 |
+------------+

(ii)

SELECT MAX(Marks) AS Max_Marks, MIN(Marks) AS Min_Marks 
FROM Student;
Output
+-----------+-----------+
| Max_Marks | Min_Marks |
+-----------+-----------+
|        66 |        23 |
+-----------+-----------+

(iii)

SELECT COUNT(DISTINCT Grade) AS Different_Grades 
FROM Student;
Output
+------------------+
| Different_Grades |
+------------------+
|                3 |
+------------------+

(iv)

SELECT Grade, COUNT(*) AS Total_Students 
FROM Student
GROUP BY Grade;
Output
+-------+----------------+
| Grade | Total_Students |
+-------+----------------+
| C     |              2 |
| B     |              1 |
| A     |              2 |
+-------+----------------+

Answered By

2 Likes


Related Questions