1.
insert into newtable (newdate,...)
select dateadd(mm, 1, cast(yy+'-'+mm+'-01' as datetime)), ... from oldtable
2.
select date,prd,max(qty1),max(qty2) from 表1 group by date,prd
insert into newtable (newdate,...)
select dateadd(mm, 1, cast(yy+'-'+mm+'-01' as datetime)), ... from oldtable
2.
select date,prd,max(qty1),max(qty2) from 表1 group by date,prd
yy=2002:mm=12转换后变成了
1.1905-08-07.
insert into newtable(newdate,...)
select dateadd(mm,1,convert(datetime,yy+'-'+mm+'-01'),.... from oldtable
2----
select date,prd,
(select max(isnull(qty1,'') from table where date = b.date and prd = b.prd),
(select max(isnull(qty2,'') from table where date = b.date and prd = b.prd),
from table as b
group by date,prd
所以才出现1905-08-07 00:00:00.000 这样的结果!
能否用select case mm=12 then date=yyyyy这样形式给个写法!