You are on page 1of 2

NATIONAL INSTITUTE OF TRANSPORT

COMPUTING AND COMMUNICATION TECHNOLOGY DEPARTMENT (CCT)


HIGHER DIPLOMA TWO IN INFORMATION TECHNOLOGY (HDIT-2)
HIGHER DIPLOMA TWO IN COMPUTER SCIENCE (HDCS-2)

GROUP ASSIGNMENT (TO BE COLLECTED IN SOFTCOPY)


MODULES NAME: DATABASE SYSTEMS/DATABASE TECHNOLOGIES
MODULE CODE: ITU 07307/ITU 07301 Total Marks: 10
SUBMISSION DATE:

INSTRUCTION:
➢ Use the Sample Database Given in a File named GPAdatabase.sql to Answer the Question

QUESTION
Given the sample of the GPADatabase in a file, write SQL Stored function called calculateGPA
which receive student’s registration number, semester and academic year and return the
corresponding semester GPA truncated to one decimal place.
NOTE:

GPA = Σ (Grade Points x Credits)


Σ Credits
Truncation means to discard the remaining. That is 3.9999 = 3.9 when truncated to one
decimal place
Example of GPA Calculation
Test your function against the following query, changing the value of the studentID and
semester
select studentID, aYear, semester, calculateGPA(studentID, aYear, semester) from enrollment
where studentID='NIT/BLTM/2017/214' AND ayear='2017/2018' AND semester=1 limit 1;

Compare your results against these output


studentID aYear Semester GPA
NIT/BLTM/2017/214 2017/2018 1 3.4
NIT/BLTM/2017/214 2017/2018 2 2.9
NIT/BLTM/2017/215 2017/2018 1 0.9
NIT/BLTM/2017/215 2017/2018 2 2.8
NIT/BLTM/2017/216 2017/2018 1 3.0
NIT/BLTM/2017/216 2017/2018 2 3.2
NIT/BLTM/2017/217 2017/2018 1 5.0
NIT/BLTM/2017/217 2017/2018 2 4.7

Golden HINT:
Use combination of SQL Counter Controlled While loop and SQL if—else-if structures to help
solve the question

You might also like