我有以下查询从 2 个子查询中获取计数,它应该给我两个计数的平均值。它在最后一个查询中给出了 C1 错误。
Select c0.hour , AVG(c0.frequency)as 'AVG In', AVG(c1.frequency)as 'AVG Out' from
(SELECT [Network]
,cast ([date time]as date)as 'date'
,datepart(hh,[date time])as 'hour'
,[Scan Type]
,count ([scan type])as frequency
FROM [Pallex-DW].[dbo].[Scans]
where Network like 'fr'and [Scan Type] like '3'
group by Network ,datepart(hh,[date time]),cast ([date time]as date),[Scan Type])as c0
Union
(SELECT [Network]
,cast ([date time]as date)as 'date'
,datepart(hh,[date time])as 'hour'
,[Scan Type]
,count ([scan type])as frequency
FROM [Pallex-DW].[dbo].[Scans] as c1
where Network like 'fr'and [Scan Type] like '11'
group by Network ,datepart(hh,[date time]),cast ([date time]as date),[Scan Type])c1