27,580
社区成员
发帖
与我相关
我的任务
分享
insert a(time,total,vis0,vis1,vis2,type)
select convert(varchar(10),getdate(),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),getdate(),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),getdate(),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),getdate(),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),getdate(),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),getdate(),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),getdate(),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]<dateadd(day,1,convert(varchar(10),getdate(),120))
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]<dateadd(day,1,convert(varchar(10),getdate(),120))
'顶
insert into A(time,total,vis0,vis1,vis2,type)
select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表B' from 表B where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表C' from 表C where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表D' from 表D where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表E' from 表E where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表F' from 表F where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表G' from 表G where datediff(dd,date,getdate())=1
union select convert(char(10),date,120),count(*),sum(case vis when 0 then 1 else 0 end),sum(case vis when 1 then 1 else 0 end),sum(case vis when 2 then 1 else 0 end),'表H' from 表H where datediff(dd,date,getdate())=1