运行此查询时收到错误消息 147。我正在查找评论包含 DBA 且未过期或过期日期为空的所有记录,但我需要查看具有此条件的最新记录。我也不确定如何格式化 hte date 以获取“2013-09-18 00:00:00”格式的当前日期,以便可以随时运行查询,而无需对日期进行硬编码。我的选择语句中也有 MIN() 因为它让我在那里插入了一些东西......我应该用其他东西代替它吗?
SELECT
AD.AccountNumber AS ACCOUNTNUMBER,
MIN(AD.SharePrimeNameLongName) AS NAME,
MIN(AD.SharePrimeNameSSN) AS SSN,
MIN(AD.SharePrimeNameSSNType) AS SSNTYPE,
MIN(C.COMMENT) AS COMMENT
FROM
ARCU.ARCUShareDetailed AS AD JOIN
COMMENT AS C ON
AD.AccountNumber = C.PARENTACCOUNT
WHERE
AD.AccountStatus = 'OPEN' AND
(C.ProcessDate = (Select MAX(AD.ProcessDate) from COMMENT having
C.COMMENT Like '%DBA') AND
((C.EXPIRATIONDATE > '2013-09-18 00:00:00') OR
(C.EXPIRATIONDATE IS NULL)))
ORDER BY AccountNumber