我们可以在MS Access 2013中为查询构建临时表吗?或者一切都必须在嵌套查询中完成。
例如:
Select
FacilityID
,ActivityID
ClientID
Into
#Clients
From
Activities
然后 做点什么
Select
FacilityID
,Count(ClientID) Over (partition By ActivityID) as ActivityCount
Into
#Final
From
#Clients
这已经简化了 - 但你应该有一个想法。
谢谢,
答案 0 :(得分:4)
如果从VBA代码运行查询,则可以在Access中执行此操作。您不能使用像Update或Make Table这样的操作查询作为另一个查询的行源,因此您必须首先构建源表。
Dim db as DAO.Database
Set db = CurrentDb()
db.Execute _
"SELECT FacilityID, ActivityID, ClientID " & _
"INTO Clients " & _
"FROM Activities;", _
dbFailOnError
db.execute _
"SELECT FacilityID, ... " & _
"INTO Final " & _
"FROM Clients;", _
dbFailOnError
(COUNT ... OVER (PARTITION BY ...)
代码已被删除,以防止Access SQL支持该构造的错误印象。但事实并非如此。)