You are on page 1of 2

4. Create a student table having attributes as Roll No. , Name , Marks and insert at least four data.

Implement
SQL commands on the student table and find the min, max, sum and average marks.

mysql> create database school;

mysql> use school;

mysql> create table student(roll int,name varchar(15),marks int);

mysql> insert into student values(101,"Jack",50),(102,"Jill",60),(103,"Harry",70),(104,"Tom",80);

mysql> select min(marks) from student;

Output:

+------------+

| min(marks) |

+------------+

| 50 |

+------------+

mysql> select max(marks) from student;

Output:

+------------+

| max(marks) |

+------------+

| 80 |

+------------+

mysql> select sum(marks) from student;

Output:

+------------+

| sum(marks) |

+------------+

| 260 |

+------------+

mysql> select round(avg(marks),2) as average from student;

Output:

+---------+

| average |

+---------+

| 65.00 |
+---------+

You might also like