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 |
|
SteveInBeloit
Starting Member
1 Post |
Posted - 2007-10-12 : 16:31:44
|
| Hi,Two tables, Account and Details:Account has Acctnum and DescDetail has Acctnum, Date, and Balance.For each Accntnum in Account, I have multiple rows in Details with that acctnum, a date, and a balance.I need to select all accounts form Account, and the balance from the Details row that has the most recent Date on it. So the most recent balance.?? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-10-12 : 16:41:16
|
| Use a JOIN between the two tables, GROUP BY the accountnum, and MAX on the date.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2007-10-15 : 04:28:22
|
| SELECT MAX(date), AccountNum FROM Account as AINNER JOIN Detail as D ON A.AccountNum = D.AccountNum GROUP BY accountNumJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
|
|
|