select bianhao, sum( pv ) as pv
from h_order
where riqi between '2005-01-01 00:00:00' and '2005-01-02 00:00:00'
group by bianhao

解决方案 »

  1.   

    zarge(鲨去来兮) 的正确 你的问题就是一个分组!!!
      

  2.   

    insert into 汇总表(bianhao,pv)
    select 
        bianhao,
        sum(pv)
    from 
        h_order
    where 
        riqi between cast('2005-01-01 00:00:00' as datetime) 
                 and cast('2005-01-02 00:00:00' as datetime) 
    group by 
        bianhao
      

  3.   

    insert into 另一个表(bianhao,pv)
    select bianhao,pv=sum(pv) from h_order group by bianhao,convert(varchar(10),riqi,120)
      

  4.   

    insert into 另一个表(bianhao,pv)
    select bianhao,pv=sum(pv) from h_order 
    where cast(convert(varchar(10),riqi,120)  as datetime) between '2005-01-01' and '2005-01-02'
    group by bianhao,convert(varchar(10),riqi,120)
      

  5.   

    --------請試下面的語句----
    insert into 另一个表(bianhao,pv)
    select bianhao,pv=sum(pv) from h_order 
    where cast(convert(varchar(10),riqi,120)  as datetime) between '2005-01-01' and '2005-01-02'
    group by bianhao,convert(varchar(10),riqi,120)
      

  6.   

    insert into 汇总表(bianhao,pv)
    select bianhao,sum(pv)
    from h_order
    where riqi >= cast('2005-01-01 00:00:00' as datetime) and riqi<= cast('2005-01-02 00:00:00' as datetime) 
    group by bianhao