SQL 2008 R2
Hi All,
I have this data below, I have a unique ID. There are mutiple contract numbers with a transaction date.
My end goal result is to have 1 record, the criteria to have one record is that I need to have the max transaction date. So what I would like to achieve is have a delete query that will delete all invalid records. In the sample data below, you will see that there is a duplicate max transactiondate, in this case I would want to keep the max id from these 2 records.
[pre]
UniqueID ContractNo Transactiondate
253417 555874 2/21/2002
253418 555874 7/24/2003
253419 555874 10/23/2003
253420 555874 8/27/2015
253421 555874 10/27/2015
253422 555874 10/27/2015
[/pre]
Would it be possible to achieve this in one delete query?
Many thanks
Michael
Hi All,
I have this data below, I have a unique ID. There are mutiple contract numbers with a transaction date.
My end goal result is to have 1 record, the criteria to have one record is that I need to have the max transaction date. So what I would like to achieve is have a delete query that will delete all invalid records. In the sample data below, you will see that there is a duplicate max transactiondate, in this case I would want to keep the max id from these 2 records.
[pre]
UniqueID ContractNo Transactiondate
253417 555874 2/21/2002
253418 555874 7/24/2003
253419 555874 10/23/2003
253420 555874 8/27/2015
253421 555874 10/27/2015
253422 555874 10/27/2015
[/pre]
Would it be possible to achieve this in one delete query?
Many thanks
Michael