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
insert into 另一个表(bianhao,pv) select bianhao,pv=sum(pv) from h_order group by bianhao,convert(varchar(10),riqi,120)
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)
--------請試下面的語句---- 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)
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
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
select bianhao,pv=sum(pv) from h_order group by bianhao,convert(varchar(10),riqi,120)
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)
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)
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