将域聚合更改为SQL语句
我强烈需要将此代码更改为sql普通子查询:将域聚合更改为SQL语句,sql,vba,ms-access,Sql,Vba,Ms Access,我强烈需要将此代码更改为sql普通子查询: SELECT DATEDIFF("D", "DLAST(opendate)", "Table1", "ItemId=1 and opendate is not null", "DLAST(closedate)", "Table1", "ItemId=1 and closedate is not null"); 我
SELECT DATEDIFF("D", "DLAST(opendate)", "Table1", "ItemId=1 and opendate is not null", "DLAST(closedate)", "Table1", "ItemId=1 and closedate is not null");
我怎么能这么做 这应该可以:
SELECT DateDiff("d", Last(OpenDate), Last(CloseDate))
FROM Table1
WHERE ItemId = 1
也许:
SELECT DateDiff("d", Last(OpenDate), Last(CloseDate))
FROM Table1
WHERE ItemId = 1 AND OpenDate Is Not Null AND CloseDate Is Not Null
这种SQL尝试毫无意义。编辑问题以文本表的形式显示示例数据和所需输出。我现在正在使用它。它返回一个项目的一个表的两个日期之间的日差。但我更喜欢使用子查询。比如:选择datediff(“d”,选择last(closedate)…,选择last(opendate)…你复制/粘贴了那个SQL吗?看起来引号和括号放错了位置。