-1
我試圖讓JSON對象的結果值作爲創建JSON格式
{
year: 2015,
count : 10,
children[{
month: Jan,
count: 1,
children: [{
date: 01,
count: 1
},
{
date: 11,
count: 1
}]
},
{
month: feb,
count: 2,
children: []
}]
}
從日期,其計查詢。我已經部分完成了年份和日期。對於月份,我需要根據月份檢索孩子。
select row_to_json(t)
from ( select EXTRACT(year FROM pr_created_on) as year, (select array_to_json(array_agg(row_to_json(jd)))
from (
select count(project_id), EXTRACT(month FROM pr_created_on) as month,(select array_to_json(array_agg(row_to_json(js)))
from (
select to_char(pr_created_on, 'dd') as date,EXTRACT(month FROM pr_created_on) as month, count(project_id) from projects
where EXTRACT(year FROM pr_created_on) = '2015' and to_char(pr_created_on, 'dd') between '01' and '30' group by month,date order by date
) js) as children
from projects
where EXTRACT(month FROM pr_created_on) between '01' and '12' AND EXTRACT(year FROM pr_created_on) = '2015' group by month
) jd
) as children from projects j where EXTRACT(year FROM pr_created_on) = '2015' group by year) as t`
我嘗試創建D3使用日期爲年,月,日一分級柱狀圖。爲此,我需要JSON格式的結果集 – harsith
好吧,所以你使用AJAX檢索數據? – AgentSquidflaps
是隻使用ajax ... – harsith