本帖最后由 haohaodigua 于 2011-06-05 11:48:54 编辑

解决方案 »

  1.   

    啊  什么?  贴到 mysql 区域吗  我没怎么弄过  不好意思 
      

  2.   

    select
    t3.manager,
    max(case t1.cust_type when '01' then t1.cust_typeC else 0 End) a,
    max(case t1.cust_type when '02' then t1.cust_typeC else 0 End) b,
    max(case t1.cust_type when '03' then t1.cust_typeC else 0 End) c,
    max(case t2.cust_belong when '01' then t2.cust_belongC else 0 End) d,
    max(case t2.cust_belong when '02' then t2.cust_belongC else 0 End) e,
    max(case t2.cust_belong when '03' then t2.cust_belongC else 0 End) x
    from
    (select m.manager , m.cust_type , count(1) cust_typeC from b_customer_base_info_t m group by  m.manager , m.cust_type) t1,
    (select m.manager , m.cust_belong , count(1) cust_belongC from b_customer_base_info_t m group by  m.manager ,m.cust_belong) t2,
    (select m.manager  from b_customer_base_info_t m group by  m.manager ) t3
    where t3.manager = t1.manager
    and t3.manager = t2.manager
    group by t3.manager