nothing is easy; however, it is rarely impossible
OK,
Lets go back to the origninal post:
From NarenKer's last post:
We now know that [CarNo] should be unique and PK in another table.
we now know that [SrvcID] should be unique and PK in tbl_service.
Is it possible for a given [CarNo] to have the same [ServiceDT] with different [SrvceID] for each record such as in an invoice for services... say something along the lines of refueling?
As NeoPa stated... is there the possiblity that the records are batch entered by many service stations; thus the highest [SrvcID] may not reflect the newest date?
If both are true, that the highest [SrvcID] is not related to the newest date then I suspect that you might not be able to do this reliably without some more information.
-z
OK,
Lets go back to the origninal post:
...The requirement is to get the latest serviced date for each car in the table ...
...largest SrvcID for a car would be the latest SrvcID for the same. Similarly I have to get largest SrvcIDs for each car in the table...
...largest SrvcID for a car would be the latest SrvcID for the same. Similarly I have to get largest SrvcIDs for each car in the table...
We now know that [CarNo] should be unique and PK in another table.
we now know that [SrvcID] should be unique and PK in tbl_service.
Is it possible for a given [CarNo] to have the same [ServiceDT] with different [SrvceID] for each record such as in an invoice for services... say something along the lines of refueling?
Code:
_________________________ [CarNo] [SrvcID] [ServiceDt] ------------------------- CAB123 200901 01/01/2009 CAB123 201001 01/01/2009 CAB123 201203 01/01/2009 -------------------------
If both are true, that the highest [SrvcID] is not related to the newest date then I suspect that you might not be able to do this reliably without some more information.
-z
Comment