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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Retrieve multiple latest records

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-08-31 : 19:58:31
Shawn writes "I have a table that contains accounts and the deposits that have been made to them. I have been asked to produce a report that returns all the accounts and their most recent deposit. I started out with

Select AccountNumber,Max(DepID)
From Deposits
Group By AccountNumber.

This works and returns the records I need but I can't get any other fields. They end up having to be part of the group by which then throws off the Max() Function. I have a work around but I was wondering what the right way might be to go about doing this.

Basically I need all accounts, the last deposit they made and other fields like bank name, city etc. Any idea's
Shawn PS I'm using SQL 7 on Win 2000 Professional"

   

- Advertisement -