I don't see why you need variables at all here. You need an OVER
clause to calculate the average over all the rows:
Select
'table1' as TableName,
count(*) as RecordCount,
0.75 * AVG(count(*)) over ()
from table1
where @something = specificDate
group by specificDate
union all
Select
'table2',
count(*) as RecordCount,
0.75 * AVG(count(*)) over ()
from table2
where @something = specificDate
group by specificDate;
I note that your query appears to be filtering on specificdate
. SO you can just group by the empty set: group by ()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…