M
mscertified
I need a query that will select records from a table based on a GroupId
column. For a given GroupId there can be many different Invoices (InvoiceNo
column). The InvoiceNo needs to be unique. However, the InvoiceNo may not be
unique and in those cases I need to look an another column BatchDate and take
the record for the InvoiceNo with the latest date ignoring any earlier dates.
I'm unsure as to how to structure the SQL to handle the last part of
eliminating earlier versions of invoices based on the date.
column. For a given GroupId there can be many different Invoices (InvoiceNo
column). The InvoiceNo needs to be unique. However, the InvoiceNo may not be
unique and in those cases I need to look an another column BatchDate and take
the record for the InvoiceNo with the latest date ignoring any earlier dates.
I'm unsure as to how to structure the SQL to handle the last part of
eliminating earlier versions of invoices based on the date.