我有一个性能糟糕的查询:
select COUNT(distinct accession_id) count,MONTH(received_date) month,YEAR(received_date) year
into #tmpCounts
from F_ACCESSION_DAILY
where CLIENT_ID not in (select clientid from SalesDWH..TestPractices)
group by MONTH(received_date),YEAR(received_date)
我不想等待这个查询,而是想创建一个变量或一个视图或任何其他我可以存储在服务器上的东西,并让服务器每 24 小时自动计算一次。
我想然后能够做一个select * from #tmpCounts
我怎样才能做到这一点?