3

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:

 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:

    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:

http://ruepprich.files.wordpress.com/2011/03/stacked_bar.png?w=550&h=386

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

1 Answer 1

2

When creating a chart in Apex you can click on "Chart Query Example" for some sample queries that will work with that chart type.

In the case of a stacked bar chart, the following example is given:

SELECT NULL LINK,
       ENAME LABEL,
       SAL "Salary",
       COMM "Commission"
FROM   EMP
ORDER  BY ENAME

In your case I think you'll want your query to present the following format:

SELECT NULL LINK,
       programme_name AS LABEL,
       SUM(...) AS "Unplaced",
       SUM(...) AS "Placed"
FROM ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.