--使用 CONVERT函数格式化时间,
--dateadd函数 前x天,后x天的方法
--查询后,直接插入数据
insert into [guagua_ktv].[dbo].[t_song_total] (song_name, room_id, totalnum, create_time)
();
insert into [guagua_ktv].[dbo].[t_user_total] (user_id, room_id, goldmike_num, create_time)
(
select user_id, room_id, goldmike_num, CONVERT(varchar(100),dateadd(day, -3, create_time), 20)
--select singer_uid, room_id, totalnum, create_time, goldmike
from [guagua_ktv].[dbo].[t_user_total] t
where CONVERT(varchar(100), t.create_time, 23) = '2013-08-12'
);
insert into [guagua_ktv].[dbo].[t_singer_total] (singer_uid, room_id, totalnum, create_time, goldmike)
(
select singer_uid, room_id, totalnum, CONVERT(varchar(100),dateadd(day, -3, create_time), 20), goldmike
--select singer_uid, room_id, totalnum, create_time, goldmike
from [guagua_ktv].[dbo].[t_singer_total] t
where CONVERT(varchar(100), t.create_time, 23) = '2013-08-12'
);