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
 Transact-SQL (2000)
 Select single record from duplicate records

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-26 : 11:03:14
supreme writes "I have multiple records in a table.
Ex. Name , number, date.
I like to retrieve all the names and numbers that did business with us. But the same names might have done business multiple times. I need the last time that they did business with us.The latest record for each name."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-04-26 : 11:18:50
select distinct

<O>
Go to Top of Page

MuffinMan
Posting Yak Master

107 Posts

Posted - 2002-04-26 : 11:24:08

select a.*
from MyTable a
inner join (
Select Name, Number, Max(Date) as Date
from MyTable
group by Name, Number
) b
on a.Name = b.Name and a.Number = b.Number and a.Date = b.Date


Go to Top of Page
   

- Advertisement -