日期:2014-05-18 浏览次数:20380 次
insert a(time,total,vis0,vis1,vis2,type) select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'B' as type from B where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'C' as type from C where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'D' as type from D where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'E' as type from E where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'F' as type from F where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'G' as type from G where [Date]>=convert(varchar(10),getdate(),120) and [Date]<dateadd(day,1,convert(varchar(10),getdate(),120)) union all select convert(varchar(10),[date],120) as Time, count(1) as total, sum(case vis when 0 then 1 else 0 end) as vis0, sum(case vis when 0 then 1 else 0 end) as vis1, sum(case vis when 0 then 1 else 0 end) as vis2, 'H' as type from H where [Date]>=convert(varchar(10),getdate(),120) and [Date]<da