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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-08-29 : 09:32:47
|
Ram writes "Hi there,If I've CUST ID, TRANSACTION DATE (TXN_DT), and few other important attrobutes along with these two in a DB2 table.I want to find out Each customer, his latest Transaction Date, and all other corresponding attributes on that last Activity (TXN_DT) date.Without writing multiple sub queries, can I get it in one stright sql? If not in one sql, what can be the best SQL to get this info? Thanks,Ram" |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-29 : 09:37:58
|
Use derived table instead.SELECT w.*FROM MyTable wINNER JOIN (SELECT Cust_ID, MAX(Transaction_date) mdt FROM MyTable group by cust_id) x on x.cust_id = w.cust_id and x.mdt = w.transaction_datePeter LarssonHelsingborg, Sweden |
|
|
|
|
|