Hi all,
Does MS Jet SQL support Derived tables? I'll tell you what i'm doing and see what you come up with.
I have an audit log of account changes. Fields are Id, ChangeDate, ChangeType, AccountNumber
There is one record per change on each account. What i need is the last change of a specific type for each account number. I've tried 2 methods:
Subquery
Select *
From tblAuditLog
Where id In
(
Select max(id)
From tblAuditLog
Where ChangeType like '%EXTSTATUS'
Group By accountno
)
;
This works but is hellishly slow. Note also that the Max(ID) also conveniently relates to the last change for the account (i.e the Max Date). I also tried this derived table:
Select *
From (
Select max(id) as id2
From tblAuditLog
Where ChangeType like '%EXTSTATUS'
Group By accountno
) As DervdTbl
Inner Join tblauditlog OrigTbl
On DervdTbl.id2=OrigTbl.id
This was created by me in Queryman and worked when i connected to the access database but when tried in access itself gave a syntax error.
Any suggestions?
Thanks
Unifec
Does MS Jet SQL support Derived tables? I'll tell you what i'm doing and see what you come up with.
I have an audit log of account changes. Fields are Id, ChangeDate, ChangeType, AccountNumber
There is one record per change on each account. What i need is the last change of a specific type for each account number. I've tried 2 methods:
Subquery
Select *
From tblAuditLog
Where id In
(
Select max(id)
From tblAuditLog
Where ChangeType like '%EXTSTATUS'
Group By accountno
)
;
This works but is hellishly slow. Note also that the Max(ID) also conveniently relates to the last change for the account (i.e the Max Date). I also tried this derived table:
Select *
From (
Select max(id) as id2
From tblAuditLog
Where ChangeType like '%EXTSTATUS'
Group By accountno
) As DervdTbl
Inner Join tblauditlog OrigTbl
On DervdTbl.id2=OrigTbl.id
This was created by me in Queryman and worked when i connected to the access database but when tried in access itself gave a syntax error.
Any suggestions?
Thanks
Unifec