我有学生表和学生课程表。我正在计算学生为获得认证而完成的课程的百分比。我没有显示百分比,而是要求显示如下状态:
Percent Complete = 0; Training Status would be Assigned; Certification
Status-N/A Percent Complete = 33;Training Status would be In-Progress;
Certification Status-Pending Percent Complete = 66;Training Status
would be Complete; Certification Status-In-Progress
如何计算百分比并显示上述措辞而不是百分比?
SELECT CONCAT(Student.LastName,', ', Student.FirstName) AS "FULL NAME",
studentcourse.CourseID as "COURSE",
studentcourse.Status AS "TRAINING STATUS", studentcourse.PercentComplete,
studentcourse.status as 'CERTIFICATION STATUS'
FROM studentcourse, student, Course
where Student.OrgID='DECC'
AND student.studentID=studentcourse.StudentID
AND Student.IsActiveFlag='1'
AND Course.CourseID=StudentCourse.CourseID
示例数据:正在删除百分比列。
FULL NAME COURSE TRAINING STATUS %Complete CERT STATUS
Adkins, Willa DECC_PER not attempted 0 not attempted
Adkins, Willa LMS_Training_DECC not attempted 0 not attempted
Akers, Dianne DECC_PER not attempted 0 not attempted
Akers, Dianne LMS_Training_DECC not attempted 0 not attempted
Alexander, Richard DECC_PER not attempted 0 not attempted
Alexander, Richard LMS_Training_DECC not attempted 0 not attempted
Altamirando, Ardella 8570_Pending_CE_NE completed 100 completed
Altamirando, Ardella 8570_Pending_IA completed 100 completed
尝试使用 CASE 但出现语法错误。