--分类统计各年龄段人数
select count(a) ,count(b),count(c),count(d),count(e),count(f),count(g) from
(
select
(case when age <50 then t.oid end) a,
(case when age between 50 and 60 then t.oid end) b,
(case when age between 60 and 70 then t.oid end) c,
(case when age between 70 and 80 then t.oid end) d,
(case when age between 80 and 90 then t.oid end) e,
(case when age between 90 and 100 then t.oid end) f,
(case when age >100 then t.oid end) g
from oldpeopleinfor t
)
--多条select语句的统计
select count(a),count(b) from
(
select
(case when x.community in(select actualname from userinfor where type='社区') then x.oid end) a,
(case when x.street in(select itemnote from dictitem) then x.oid end) b
from oldpeopleinfor x
)