Modifying SELECT query to create Stacked Bar Chart

admin

Administrator
Staff member
I have a query for a Placement Application Tracking System which shows the number of students placed and unplaced per programme of study. I'm struggling to create an APEX Stacked Bar Chart out of it, even though the query returns the desired results.

Query:

Code:
 SELECT programme_name,
           SUM(CASE WHEN (cv_approval_date IS NOT NULL AND application_status_id <> 7) OR
                         application_status_id  IS NULL
                    THEN 1 ELSE 0 END) as Unplaced,
           SUM(CASE WHEN (cv_approval_date IS NOT NULL AND application_status_id <> 7) OR
                         application_status_id  IS NULL
                    THEN 0 ELSE 1 END) as Placed
    FROM programme LEFT JOIN
         student USING (programme_id) LEFT JOIN
         application USING (student_id)
    GROUP BY programme_name;

Output:

Code:
    PROGRAMME_NAME                                | PLACED   | UNPLACED
    BSc (Hons) Computer Science                   | 2        | 2 
    BSc (Hons) Computing and Games Development    | 1        | 0 
    BSc (Hons) Web Applications Development       | 0        | 1 
    BSc (Hons) Marine Biology and Coastal Ecology | 1        | 0

The graph is supposed to look similar to this - the x axis being Programme, y axis being number of students placed, and unplaced:

<a href="http://ruepprich.files.wordpress.com/2011/03/stacked_bar.png?w=550&amp;h=386" rel="nofollow">http://ruepprich.files.wordpress.com/2011/03/stacked_bar.png?w=550&amp;h=386</a>

How might I go about doing this? Any help would be greatly appreciated!