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
Currently That is the query i have which produces the result
Jan Feb Mar Apr .....
1 3 1 2
now i want to display this information in a line graph so it looks like this joined up
3 x
2
1 x x
jan feb mar
Being abit of a noob with charts i cant get it to work when i try to use my current query. any help much appreciated
If you really want to go with ASCII graphics, and in lieu of something more elaborate, you could build on
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
;
with "Result" being your query against Table1.
See SQL Fiddle (Switch to plain text output to see the columns properly aligned.)
Did you give Building Charts, Gantts and Maps with Oracle Application Express 4.0 a try? Please comment, if and as adjustment / further detail is required.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.