[code="java"]select f.pc_name,
f.phc_name,
(select count(1)
from p_resident c
where c.phc_id = f.phc_id
and c.pr_income is not null
and c.pr_income < 4000) fourqian,
(select count(1)
from p_resident c
where c.phc_id = f.phc_id
and c.pr_income is not null
and c.pr_income >= 4000
and c.pr_income < 5000) fourfiveqian,
(select count(1)
from p_resident c
where c.phc_id = f.phc_id
and c.pr_income is not null
and c.pr_income >= 5000
and c.pr_income < 6000) fivesixqian,
(select count(1)
from p_resident c
where c.phc_id = f.phc_id
and c.pr_income is not null
and c.pr_income >= 6000
and c.pr_income < 7000) sixsevenqian,
(select count(1)
from p_resident c
where c.phc_id = f.phc_id
and c.pr_income is not null
and c.pr_income >= 7000) sevenqian
from (select t.pc_name, a.phc_name, a.phc_id
from p_community t, p_home_community a
where t.pc_id = a.pc_id
and t.pc_id in
(select c.po_id
from p_organization c
start with c.po_id = 5027
connect by prior c.po_id = c.po_parent_id)) f
[/code]
按地区统计各个阶段收入的个数,查询要好长时间