insert into t2 from (select 单位,count(1) as 数量 from t1 group by 单位) as t

解决方案 »

  1.   

    insert into t2 select 单位,count(1) as 数量 from t1 group by 单位
      

  2.   

    若t2表不存在
    select 单位,count(1) as 数量 into t2 from t1 group by 单位
    若t2表存在
    insert into t2 select 单位,count(1) as 数量 from t1 group by 单位
      

  3.   

    select 单位,count(1) as 数量 into t2 from t1 group by 单位
      

  4.   

    insert into t2 
       select 单位,count(*) as 数量 from t1 group by 单位
      

  5.   

    insert t2 select 单位,count(*) from t1 group by 单位
      

  6.   

    select 单位,count(*) 数量 from table group by 单位
    用group by 分组select 单位,性别,count(*) 数量 from table group by 单位.性别
    还可以对性别分组统计