### 在查询访问中计算计算字段

SELECT Positions.[Req #], tblPositionList.PositionName,
Positions.[Opening Date], Positions.[Close Date],
Positions.Status, Count([OpenPosition]![Close Date]) AS Closed,
Positions.Openings AS Opened, [Opened]-[Closed] AS Remaining
FROM tblPositionList INNER JOIN (
Positions INNER JOIN OpenPosition ON Positions.[Req #] = OpenPosition.[Req #])
ON (tblPositionList.PositionID = Positions.PositionID) AND
(tblPositionList.PositionID = OpenPosition.PositionID)
GROUP BY Positions.[Req #], tblPositionList.PositionName, Positions.[Opening Date],
Positions.[Close Date], Positions.Status, Positions.Openings;

#### 1 个答案:

SELECT Positions.[Req #], tblPositionList.PositionName, Positions.[Opening
Date], Positions.[Close Date], Positions.Status, Count([OpenPosition]![Close
Date]) AS Closed, Positions.Openings AS Opened, Positions.Openings-
Count([OpenPosition]![Close Date]) AS Remaining
FROM tblPositionList INNER JOIN (Positions INNER JOIN OpenPosition ON
Positions.[Req #] = OpenPosition.[Req #]) ON (tblPositionList.PositionID =
Positions.PositionID) AND (tblPositionList.PositionID =
OpenPosition.PositionID)
GROUP BY Positions.[Req #], tblPositionList.PositionName, Positions.[Opening
Date], Positions.[Close Date], Positions.Status, Positions.Openings
HAVING (((Positions.Openings-Count([OpenPosition]![Close Date]))>0));