我有以下SQL查询返回日期,我需要评估日期,结果只比今天的日期早一天。
SELECT Address,
max(Date+ ' ' + time)as last_Trans_time
FROM AxA_Transactions
where address is not null
GROUP BY Address
答案 0 :(得分:0)
如果我正确地理解你的问题(特别是关于"只有今天比今天更早的日期和#34;意味着什么),我相信这应该可以解决问题:
SELECT *
FROM
(
SELECT [Address],
MAX([Date] + ' ' + [time]) AS last_Trans_time
FROM AxA_Transactions
WHERE [Address] IS NOT NULL
GROUP BY [Address]
) info
WHERE CONVERT(DATE, info.last_Trans_time) = CONVERT(DATE,GETDATE() - 1)