0% found this document useful (0 votes)
18 views4 pages

Aggregate Functions ROLL NO: 71762303 114 Name: Shavya S S

The document shows how to use aggregate functions like count, sum, average, maximum and minimum in SQL to analyze student data from a table with columns like register number, name, section, subject marks. Examples are provided to count the number of students, get subject total marks for each student, and find class average, maximum and minimum marks for each subject.

Uploaded by

appathangam.2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Aggregate Functions ROLL NO: 71762303 114 Name: Shavya S S

The document shows how to use aggregate functions like count, sum, average, maximum and minimum in SQL to analyze student data from a table with columns like register number, name, section, subject marks. Examples are provided to count the number of students, get subject total marks for each student, and find class average, maximum and minimum marks for each subject.

Uploaded by

appathangam.2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

AGGREGATE FUNCTIONS

ROLL NO: 71762303 114

NAME: SHAVYA S S

Use Aggregate Functions to find the following:

SQL> CREATE TABLE Student ("register number" NUMBER (15),"student name" CHAR
(20), section NUMBER(15), "subject 1 mark" NUMBER(4),"subject mark 2" NUMBER(4));

Table created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('111','Satha nandhini','2','90','95');

1 row created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('112','Shalini','2','92','94');

1 row created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('022','Kaaviya','1','89','90');

1 row created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('055','Subiksha','1','90','96');

1 row created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('101','Shyama','2','85','89');

1 row created.
SQL> INSERT INTO Student("register number","student name",section,"subject 1
mark","subject mark 2")VALUES('114','Shavya','2','97','90');

1 row created.

SQL> INSERT INTO Student("register number","student name",section,"subject 1


mark","subject mark 2")VALUES('084','Iniya','2','97','99');

1 row created.

i) Number of Students in the class

SQL> SELECT COUNT ("student name") FROM Student;

COUNT("STUDENTNAME")

--------------------

ii) Sum of Marks in Subject I & Subject II Student-wise.

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Satha nandhini';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

185

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Shalini';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

186

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Kaaviya';
SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

179

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Subiksha';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

186

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Shyama';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

174

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Shavya';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

187

SQL> SELECT SUM ("subject 1 mark"+"subject mark 2") From Student WHERE "student
name"='Iniya';

SUM("SUBJECT1MARK"+"SUBJECTMARK2")

----------------------------------

196

iii) Class average of marks in Subject I & Subject II.

SQL> Select AVG ("subject 1 mark") FROM Student;

AVG("SUBJECT1MARK")

-------------------

91.4285714
SQL> Select AVG ("subject mark 2") FROM Student;

AVG("SUBJECTMARK2")

-------------------

93.2857143

iv) Maximum mark in Subject I & Subject II for the class.

SQL> SELECT MAX ("subject 1 mark") FROM Student;

MAX("SUBJECT1MARK")

-------------------

97

SQL> SELECT MAX ("subject mark 2") FROM Student;

MAX("SUBJECTMARK2")

-------------------

99

v) Minimum mark in Subject I & Subject II for the class.

SELECT MIN ("subject 1 mark") FROM Student;

MIN("SUBJECT1MARK")

-------------------

85

SQL> SELECT MIN ("subject mark 2") FROM Student;

MIN("SUBJECTMARK2")

-------------------

89

You might also like