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)
 SQL Basics Question

Author  Topic 

Alex2011
Starting Member

18 Posts

Posted - 2011-04-27 : 14:04:30
HI, I am a beginner of SQL and wanted to get some help.

select col1, max(col3) as maxcol3
from table
group by col1

col1 col2 col3
a a-3 20
a a-0 80
b b-9 100
b b-3 200

I want to add col2 and its value should be from the row where max(col3) exists. so the return for above would be

col1 col2 col3
a a-0 80
b b-3 200

how to change the SQL statements above to achieve this.

Appreciate any help.

Alex

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-27 : 14:08:34
Dupe: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159980

Since we continued the original thread, let's stay there. Just keep it in mind for the future, don't double-post.
Go to Top of Page
   

- Advertisement -