In this tutorial I explained how to Create a Student marks table using MySQL and apply aggregate functions using SQL queries. Actually aggregate functions are used to perform the mathematical operations like find the average, sum, minimum and maximum values in the particular tables.
However it’s not possible in students marks table because we can’t able to do multiple column in aggregate function. It’s perfect for few only like sum and count, otherwise we can’t to find average results. Alternatively we can directly perform the formula to getting a results.
Also Read – Retrieve Records using SQL Clauses
Create a Student Marks Table | Aggregate Function
Totally five most used aggregate functions are available. Such as,
- Count()
- Min()
- Max()
- Avg()
- Sum()
Video Tutorial Tamil | create a student marks
We are clearly explained in Tamil language for how create a student marks table using aggregate function in MySQL queries.
Source Code
In below we are sharing the source the code, if you are facing any issues just comment below we are helsp to solve the issues. Moreover we are also providing software courses in very affordable prices. So if you are interested then please enroll the course in our official website.
show databases;
CREATE DATABASE KAMARAJCOLLEGE;
USE KAMARAJCOLLEGE;
CREATE TABLE STUDENT_MARKS (
STU_REGNO INT PRIMARY KEY,
STU_NAME VARCHAR(100),
STU_DEGREE VARCHAR(50),
MYSQL_LABMARKS INT
);
SHOW TABLES;
DESCRIBE STUDENT_MARKS;
INSERT INTO STUDENT_MARKS (STU_REGNO,STU_NAME,STU_DEGREE,MYSQL_LABMARKS)
VALUES (125,'VIGNESH','BSC',100);
SELECT * FROM STUDENT_MARKS;
SELECT COUNT(STU_DEGREE) FROM STUDENT_MARKS;
SELECT STU_NAME, COUNT(STU_NAME) FROM STUDENT_MARKS GROUP BY STU_NAME;
SELECT SUM(MYSQL_LABMARKS) AS TOTAL FROM STUDENT_MARKS;
SELECT SUM(MYSQL_LABMARKS+PYTHON_MARKS) AS TOTAL_MARKS FROM STUDENT_MARKS WHERE STU_REGNO='123';
SELECT AVG(MYSQL_LABMARKS) AS TOTAL_AVERAGE FROM STUDENT_MARKS;
SELECT MAX(MYSQL_LABMARKS) FROM STUDENT_MARKS;
SELECT STU_NAME,MYSQL_LABMARKS AS FIRST_MARKS FROM STUDENT_MARKS WHERE MYSQL_LABMARKS = (SELECT MAX(MYSQL_LABMARKS) FROM STUDENT_MARKS);
SELECT MIN(MYSQL_LABMARKS) FROM STUDENT_MARKS;
SELECT STU_NAME,MYSQL_LABMARKS AS LAST_MARKS FROM STUDENT_MARKS WHERE MYSQL_LABMARKS = (SELECT MIN(MYSQL_LABMARKS) FROM STUDENT_MARKS);
Output for Aggregate Function
I hope above videos and source code helps to solve your doubts and errors. If you are facing any issues on the exercise then feel free to comment below, I am help to solve the doubts.
![Create a Student Marks Table using MySQL and Apply Aggregate Function](https://www.vetbossel.in/wp-content/uploads/2023/12/Create-a-Student-Marks-Table-using-MySQL-and-Apply-Aggregate-Function-1024x770.jpeg)