select count(case when extract(month from C_DATE) = 1 then 1 end) as Jan,
count(case when extract(month from C_DATE) = 2 then 1 end) as feb,
count(case when extract(month from C_DATE) = 3 then 1 end) as mar,
count(case when extract(month from C_DATE) = 4 then 1 end) as april,
count(case when extract(month from C_DATE) = 5 then 1 end) as may,
count(case when extract(month from C_DATE) = 6 then 1 end) as jun,
count(case when extract(month from C_DATE) = 7 then 1 end) as jul,
count(case when extract(month from C_DATE) = 8 then 1 end) as aug,
count(case when extract(month from C_DATE) = 9 then 1 end) as sep,
count(case when extract(month from C_DATE) = 10 then 1 end) as oct,
count(case when extract(month from C_DATE) = 11 then 1 end) as nov,
count(case when extract(month from C_DATE) = 12 then 1 end) as december
from Table1
目前这是我产生结果的查询
Jan Feb Mar Apr .....
1 3 1 2
现在我想在折线图中显示这些信息,所以它看起来像是这样的
3 x
2
1 x x
jan feb mar
当我尝试使用当前查询时,使用图表升级菜鸟我无法使其工作。任何帮助非常感谢
答案 0 :(得分:0)
如果你真的想使用ASCII图形,而不是更精细的东西,你可以建立
WITH
Line AS (
SELECT
' ' || Jan || ' ' || Feb || ' ' || Mar || ' ' || Apr || ' ' || May || ' ' || Jun || ' ' || Jul || ' ' || Aug || ' ' || Sep || ' ' || Oct || ' ' || Nov || ' ' || Dec || ' ' l
FROM Result
),
Graph (cnt, g)AS (
SELECT 5, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 5 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT 4, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 4 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT 3, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 3 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT 2, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 2 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT 1, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 1 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT 0, '#' || REGEXP_REPLACE(REGEXP_REPLACE(l, ' 0 ', ' x '), '\d+', ' ') || '#' FROM Line UNION ALL
SELECT -1, '# Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec #' FROM DUAL
)
SELECT
*
FROM Graph
ORDER BY cnt DESC
;
"结果"是您对Table1的查询。
请参阅SQL Fiddle(切换到纯文本输出以查看正确对齐的列。)
你试过Building Charts, Gantts and Maps with Oracle Application Express 4.0了吗?
如果需要调整/进一步详细说明,请发表评论。