修改 SELECT 查询以创建堆积条形图
Posted
技术标签:
【中文标题】修改 SELECT 查询以创建堆积条形图【英文标题】:Modifying SELECT query to create Stacked Bar Chart 【发布时间】:2014-12-10 22:29:35 【问题描述】:我有一个关于安置申请跟踪系统的查询,该系统显示每个学习计划安置和未安置的学生人数。即使查询返回所需的结果,我仍在努力创建一个 APEX 堆叠条形图。
查询:
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;
输出:
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
该图应该看起来与此类似 - x 轴是 Programme,y 轴是放置和未放置的学生人数:
http://ruepprich.files.wordpress.com/2011/03/stacked_bar.png?w=550&h=386
我该怎么做呢?任何帮助将不胜感激!
【问题讨论】:
【参考方案1】:在 Apex 中创建图表时,您可以点击“图表查询示例”查看适用于该图表类型的一些示例查询。
以堆积条形图为例,给出如下示例:
SELECT NULL LINK,
ENAME LABEL,
SAL "Salary",
COMM "Commission"
FROM EMP
ORDER BY ENAME
在您的情况下,我认为您希望您的查询呈现以下格式:
SELECT NULL LINK,
programme_name AS LABEL,
SUM(...) AS "Unplaced",
SUM(...) AS "Placed"
FROM ...
【讨论】:
以上是关于修改 SELECT 查询以创建堆积条形图的主要内容,如果未能解决你的问题,请参考以下文章