数据表table1:
place(地点) name(姓名) educate(教育)sh       shaaa 小学
sh shbbb 小学
sh shccc 小学
sh shddd 中学
sh sheee 大学
sh shff 大学
bj bjaaa 中学
bj bjbbb 大学
bj bjccc 大学
bj bjddd 大学
nj njaaa 大学
nj njbbb 大学
nj njccc 中学
nj njddd 小学
要求统计出每个地方,学历为小学\中学\大学的人数.即:
地点   小学   中学    大学
bj      0      1       3
nj      1      1       2
sh      3      1       2
谢谢大家!

解决方案 »

  1.   

    select place as 地点,
    sum(case educate when '小学' then 1 else then 0 end) as 小学,
    sum(case educate when '中学' then 1 else then 0 end) as 中学,
    sum(case educate when '大学' then 1 else then 0 end) as 大学
    from table1
    group by place
      

  2.   

    ORACLE :select place 地点,
    sum(DECODE(educate,'小学',1,0)) 小学,
    sum(DECODE(educate,'中学',1,0)) 中学,
    sum(DECODE(educate,'大学',1,0)) 大学
    from table1
    group by place
    SQL SERVER :见一楼
      

  3.   

    SELECT place,count(name),educate
    FROM table1 group by place,educate
    order by place
      

  4.   

    firetoucher(风焱) 每次都跑得超快!!自叹不如哦!!!
      

  5.   

    在DELPHI中,用adoquery1调用,怎么样使用?