34,577
社区成员
发帖
与我相关
我的任务
分享
if object_id('[t]') is not null drop table [t]
go
create table [t]([f1] datetime,[f4] int)
insert [t]
select '2010-01-01',3720 union all
select '2010-01-15',300000 union all
select '2010-02-8',16557 union all
select '2010-02-23',104600
go
select
'm'+ltrim(month(f1))+'-'+ltrim((datepart(dd,f1)-1)/10+1) as m,f4
from t
/**
m f4
-------------------------- -----------
m1-1 3720
m1-2 300000
m2-1 16557
m2-3 104600
(4 行受影响)
**/