 |
|
ปัญหาคือ
ไม่สามรถหาค่า 3 อย่างจากคิวรี่เพื่อคำนวณหาค่า GPA และระบุสถานะภาพของนักเรียนเปรียบเทียบ 2 เทอมคือ YRSM : 481,482
ได้แก่
คำนวณ sum(CR_HR) โดยไม่รวม GRADE ที่มี P และ W ผลรวมทั้งหมด CR_HR = 13
คำนวณ sum(GPA_2) ผลรวมทั้งหมด GPA_2 = 26.5
GPA = GPA_2/13 ผลรวมทั้งหมด 2.038
ระบุสถานะภาพของนักเรียนคือ
>=2 ค่า Normal
>=1.75 และ <2 ค่า Hight
>1.5 และ <1.75 ค่า Low
ถ้า >1.5 และ <1.75 : 2 เทอมติดกันได้ค่า OUT
< 1.5 Out
แสดงผลคิวรี่คือ student1 ,YRSM ,GPA,สถานะภาพของนักเรียน
Code (SQL)
SELECT student1.ID, student1.MAJOR, scoreed.YRSM,coursenew.CS_CODE, coursenew.COURSE_NAM, scoreed.CR_HR,scoreed.GRADE,
sum(case scoreed.GRADE
when 'A' then 4
when 'B+' then 3.5
when 'B' then 3
when 'C+' then 2.5
when 'C' then 2
when 'D+' then 1.5
when 'D' then 1
when 'F' then 0
else 0
end
) as GPA,
sum(case scoreed.GRADE
when 'A' then 4
when 'B+' then 3.5
when 'B' then 3
when 'C+' then 2.5
when 'C' then 2
when 'D+' then 1.5
when 'D' then 1
when 'F' then 0
else 0
end
) * scoreed.CR_HR as GPA_2
FROM [transcripts].[dbo].[coursenew] INNER JOIN ([transcripts].[dbo].[scoreed] INNER JOIN [transcripts].[dbo].[student1]
ON scoreed.ID = student1.ID) ON coursenew.CYEAR = scoreed.CS_CODE
WHERE (((student1.ID)='5553201')) and (((scoreed.YRSM)='481'))
GROUP BY student1.ID, student1.MAJOR, scoreed.YRSM,coursenew.CS_CODE, coursenew.COURSE_NAM, scoreed.CR_HR,scoreed.GRADE
student1 YRSM CS_CODE COURSE_NAM CR_HR GRADE GPA GPA_2
x 481 11xxxxx Soccer 1 A 4 4
x 481 13xxxxx Foundation English I 3 P 0 0
x 481 14xxxxx Chemistry 3 F 0 0
x 481 14xxxxx Calculus I 3 W 0 0
x 481 14xxxxx Introduction to Computer 3 C+ 2.5 7.5
x 481 19xxxxx Arts 3 C+ 2.5 7.5
x 481 19xxxxx Man and Society 3 C+ 2.5 7.5
Tag : PHP, Ms SQL Server 2016
|
|
 |
 |
 |
 |
Date :
2018-01-17 09:55:08 |
By :
mininovaa |
View :
665 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |