想要调整此代码以计算oracle apex中饼图的放置和未放置位置

时间:2015-10-27 12:08:11

标签: sql oracle

您好我想知道如何/在哪里可以添加计数来调整此代码以使其计算放置和未放置的学生,以便此代码可以在APEX中用于制作饼图。

SELECT programme.name 
     , CASE WHEN Current_Status = 'Applicant accepted offer' 
            THEN  'placed' 
            ELSE 'unplaced' END   AS placed
     , students.Student_first_name
     , students.student_last_name
     , students.email
     , students.CV_APPROVAL_DATE
  FROM Students
INNER 
  JOIN programme 
    ON programme.programme_id = students.programme_id
INNER 
  JOIN application 
    ON Application.SRN = students.student_record_number
 WHERE students.CV_APPROVAL_DATE IS NOT NULL
ORDER
    BY programme.name 
     , placed 

非常感谢任何帮助,感谢,到目前为止,此代码有效,并为我提供放置和未放置的活动(cv批准)学生但我需要添加一个计数以获得总放置和未放置的总数在此代码中工作

1 个答案:

答案 0 :(得分:0)

我只需添加两个子选项:

SELECT programme.name 
     , CASE WHEN Current_Status = 'Applicant accepted offer' 
            THEN  'placed' 
            ELSE 'unplaced' END   AS placed
     , students.Student_first_name
     , students.student_last_name
     , students.email
     , students.CV_APPROVAL_DATE
     , (select count(*) from Students where Current_Status = 'Applicant accepted offer') as placed_total
     , (select count(*) from Students where Current_Status <> 'Applicant accepted offer') as unplaced_total
  FROM Students
INNER 
  JOIN programme 
    ON programme.programme_id = students.programme_id
INNER 
  JOIN application 
    ON Application.SRN = students.student_record_number
 WHERE students.CV_APPROVAL_DATE IS NOT NULL
ORDER
    BY programme.name 
     , placed