Dear All,
I have a table which is mentioned below.
Branch TxnDate Field1 Field2 Field3 B1 2/20/2012 1 2 3 B1 2/23/2012 9 10 11 B2 2/20/2012 3 4 5 B2 2/24/2012 12 13 14 B3 2/20/2012 6 7 8 B3 2/25/2012 15 16 17
I need to build a SQL statement which the result should be like below
Branch TxnDate Field1 Field2 Field3 B1 2/23/2012 9 10 11 B2 2/24/2012 12 13 14 B3 2/25/2012 15 16 17
The logic of this result is
1. The Branch name should be unique
2. TxnDate is the Max(TxnDate) of each branch
3. Field1, 2, 3 values should be the corresponding values of Max(TxnDate).
Kindly help me. I have attached the database along with this.