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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write sql function to calculate GPA as seen on my image sent

 

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
MODULE
LTU 07205
LTU 07206
LTU 07207
LTU 07208
LTU 07209
GPA =
CREDITS
12
15
12
12
(4x12) + (2x15)+(4x12)+(2 x 12)+(1x0)
12 +15 +12 +12 +0
= 2.9
NIT/BLTM/2017/214
NIT/BLTM/2017/215
NIT/BLTM/2017/215
NIT/BLTM/2017/216
NIT/BLTM/2017/216
NIT/BLTM/2017/217
NIT/BLTM/2017/217
Compare your results against these output
studentID
NIT/BLTM/2017/214
SCORE
65.0
45.8
64.0
40.0
35.7
Test your function against the following query, changing the value of the studentID and
semester
aYear
2017/2018
2017/2018
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:
2017/2018
2017/2018
2017/2018
2017/2018
2017/2018
2017/2018
GRADE
B+ (4 points)
C (2 points)
B+ (4 points)
C (2 point)
D (1 point)
Semester
1
2
1
2
1
2
1
2
=
GPA
3.4
2.9
0.9
2.8
3.0
3.2
5.0
4.7
150
51
Golden HINT:
Use combination of SQL Counter Controlled While loop and SQL if-else-if structures to help
solve the question
Transcribed Image Text: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 MODULE LTU 07205 LTU 07206 LTU 07207 LTU 07208 LTU 07209 GPA = CREDITS 12 15 12 12 (4x12) + (2x15)+(4x12)+(2 x 12)+(1x0) 12 +15 +12 +12 +0 = 2.9 NIT/BLTM/2017/214 NIT/BLTM/2017/215 NIT/BLTM/2017/215 NIT/BLTM/2017/216 NIT/BLTM/2017/216 NIT/BLTM/2017/217 NIT/BLTM/2017/217 Compare your results against these output studentID NIT/BLTM/2017/214 SCORE 65.0 45.8 64.0 40.0 35.7 Test your function against the following query, changing the value of the studentID and semester aYear 2017/2018 2017/2018 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: 2017/2018 2017/2018 2017/2018 2017/2018 2017/2018 2017/2018 GRADE B+ (4 points) C (2 points) B+ (4 points) C (2 point) D (1 point) Semester 1 2 1 2 1 2 1 2 = GPA 3.4 2.9 0.9 2.8 3.0 3.2 5.0 4.7 150 51 Golden HINT: Use combination of SQL Counter Controlled While loop and SQL if-else-if structures to help solve the question
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education