Query 1: Calculate GPA for each student First you need to turn letter grade into numeric grade: A: 4.0; A-: 3.67; B+:3.3
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Query 1: Calculate GPA for each student First you need to turn letter grade into numeric grade: A: 4.0; A-: 3.67; B+:3.3
Query 1: Calculate GPA for each student First you need to turn letter grade into numeric grade: A: 4.0; A-: 3.67; B+:3.33; B: 3; B: 2.67; C+: 2.33; C: 2; C-: 1.67; D+: 1.33; D: 1; D-: 0.67; F: 0 The GPA is calculated with the following formula (Don't include null grade in the calculation): GPA = sum(numerical grade credits)/sum(credits) Here is the correct query result for your reference: name id 00128 Zhang GPA 3.858571 12345 Shankar 3.428571 3.000000 19991 Brandt 23121 Chavez 2.330000 44553 Peltier 2.670000 45678 Levy 2.029091 54321 Williams 3.500000 55739 Sanchez 3.670000 76543 Brown 4.000000 76653 Aoi 2.000000 98765 Bourikas 2.240000 98988 Tanaka 4.000000
Running Example: Schema Diagram for University Database student takes ID ID name course_id sec_id dept_name tot cred semester year grade course section course id sec_id semester course_id department title dept_name advisor s.id i id dept_name year building credits building time_slot budget room_no time_slot_id time_slot_id day start_time end_time classroom building room no capacity teaches ID course id sec_id semester year prereq course_id prereq_id instructor ID name dept name salary