34,838
社区成员




--> 测试数据: #A
if object_id('tempdb.dbo.#A') is not null drop table #A
create table #A (No int,money int,dates datetime)
insert into #A
select 1,20,'2008-01-12 12:56:21' union all
select 2,18,'2008-01-12 15:32:45' union all
select 3,31,'2008-01-12 21:16:14' union all
select 4,11,'2008-01-13 13:12:23' union all
select 5,54,'2008-01-13 15:21:32' union all
select 6,17,'2008-01-13 21:34:55' union all
select 7,12,'2008-01-14 12:56:21' union all
select 8,15,'2008-01-14 13:33:22' union all
select 9,61,'2008-01-15 10:26:36' union all
select 10,20,'2008-01-15 15:26:43'
select Money=sum(money),Dates = convert(varchar(10),dates,120) from #A group by convert(varchar(10),dates,120)
/*
Money Dates
----------- ----------
69 2008-01-12
82 2008-01-13
27 2008-01-14
81 2008-01-15
*/
select Money=sum(money),Dates = convert(varchar(10),dates,120) from tableA group by convert(varchar(10),dates,120)