SELECT TOP 1
*
FROM
tblRecap
WHERE
ID <
(
SELECT
MAX(ID)
FROM
tblRecap
)
ORDER BY
ID DESC
if there are 100 records, then what you will be getting is the 99 record and not the 2nd record.Another option:
[Date] >= DateSerial(Year(Date()), Month(Date()) - 1, 1)
AND [Date] < DateSerial(Year(Date()), Month(Date()), 1)
As a learning note, index usage is very helpful for query execution performance.When it comes to SQL I am completely lost.
' arnelgp
WHERE Format([Date],"mm/yyyy") = Format(DateAdd("m", -1, Date()),"mm/yyyy")
'ebs17
WHERE [Date] >= DateSerial(Year(Date()), Month(Date()) - 1, 1)
AND [Date] < DateSerial(Year(Date()), Month(Date()), 1)
A query is executed from the inside out. So the first step isthe query designer change it to:
SELECT TOP 1 *
FROM (SELECT T.* FROM (SELECT TOP 2 * FROM tblRecap) AS T ORDER BY T.ID DESC) AS [%$##@_Alias];
SELECT TOP 2 * FROM tblRecap