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 - 2002-02-18 : 09:29:04
|
billy jeong writes " I need to get last transaction for per account. how do i make the query? Give me some infomaiton, please. Record Account Date Value -------------------------------------- A 01/02/2000 21 A 03/04/2000 23 A 12/12/2001 32 B 03/23/2001 6 B 04/21/2001 7 ........" |
|
|
andre
Constraint Violating Yak Guru
259 Posts |
Posted - 2002-02-18 : 09:31:52
|
| Try this:SELECT Account,MAX(Date),Value FROM tblAccounts GROUP BY Account,Value; |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-02-18 : 10:55:03
|
Andre, that selects the latest date for each unique (Account, Value). Assuming that (Account, Date) is unique:SELECT *FROM tblAccounts aWHERE Date = ( SELECT MAX(Date) FROM tblAccounts b WHERE a.tblAccount = b.tblAccount) |
 |
|
|
|
|
|