Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
geossl
Yak Posting Veteran
85 Posts |
Posted - 2011-05-18 : 04:23:12
|
Dear All, There is a table, Transaction, with the following structure: <Transaction> TransactionID CustomerID TranDate Amount How to get the all CustomerID with their last transaction in an SQL? The resulting fields CustomerID LastTranDate LastAmount |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-05-18 : 04:52:33
|
| SELECT CustomerID, TransactionID, TranDate, AmountFROM [Transactions]WHERE TransactionID IN ( SELECT MAX(TransactionID) FROM [Transactions] GROUP BY CustomerID )ORDER BY CustomerID--------------------------http://connectsql.blogspot.com/ |
 |
|
|
|
|
|