简体   繁体   English

修改SELECT查询以创建堆积条形图

[英]Modifying SELECT query to create Stacked Bar Chart

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. 我正在努力创建一个APEX Stacked Bar Chart,即使查询返回了所需的结果。

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: 该图应该看起来与此类似 - x轴为Program,y轴为放置的学生数,未放置:

http://ruepprich.files.wordpress.com/2011/03/stacked_bar.png?w=550&h=386 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! 任何帮助将不胜感激!

When creating a chart in Apex you can click on " Chart Query Example " for some sample queries that will work with that chart type. 在Apex中创建图表时,您可以单击“ 图表查询示例 ”以获取将使用该图表类型的一些示例查询。

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 ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM