|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Table load with duplicates on Primary Key in import fileI am attempting to load a table with a file that has duplicates on a
composite primary key and only want to keep the newest record by a date field. Is there a way to do this with a query or will I need to set up a series of temp tables to accomplish the task. I also need to load subsequent files with duplicates on existing records in the table keeping only the newest record as per the same date field. Any help with either or both would be appreciated. SELECT * from SomeTable
INNER JOIN ( SELECT IDCol1, IDCol2, --...other id columns MAX(Datecolum) AS MaxDate FROM SomeTable GROUP BY IDCol1, IDCol2 --...other id columns ) SubQuery ON SubQuery.IDCol1 = SOmeTable.IDCol1 SubQuery.IDCol2 = SOmeTable.IDCol2 SubQuery.MaxDate = SOmeTable.Datecolum HTH, Jens Suessmeyer. |
|||||||||||||||||||||||