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)
 Function Max and group by Help

Author  Topic 

obedrodriguez
Starting Member

9 Posts

Posted - 2007-11-15 : 17:04:39
Help me with this I have this table

Name Num Description
Peter 7 Approved by Commercial Services
Norman 1 Original Calculation
John 1 Original Calculation
Kevin 1 Original Calculation
John 7 Approved by Commercial Services
Peter 1 Original Calculation

I want this result

Name Num Description
Peter 7 Approved by Commercial Services
Norman 1 Original Calculation
Kevin 1 Original Calculation
John 7 Approved by Commercial Services

I try a diffent times with max function I dont know if I using correctly I know ia have to do it with the max an group but how I do it. Thank you for the help.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-15 : 17:25:00
[code]select t.*
from table t
inner join
(
select Name, Num = max(Num)
from table
group by Name
) m on t.Name = m.Name and t.Num = m.Num[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

obedrodriguez
Starting Member

9 Posts

Posted - 2007-11-15 : 17:42:38
Thank you khtan its works :)
Go to Top of Page
   

- Advertisement -