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
 General SQL Server Forums
 New to SQL Server Programming
 Query

Author  Topic 

mageshks
Yak Posting Veteran

59 Posts

Posted - 2007-06-15 : 07:01:25


This is my table

C1 C2 C3
------------------------
1 2 1/1/2004
1 4 1/7/2004
1 4 1/9/2007
2 2 4/4/2009
3 4 1/2/2004
2 34 1/7/2007
The follwing is the result i need,
i.e., max date for each distinct value in c1

C1 c3
----------------------
1 1/9/2007
2 1/7/2007
3 1/2/2004

Thanks in Advance..,

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-15 : 07:10:31
Select c1,max(c3) as c3 from table group by c1

Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mageshks
Yak Posting Veteran

59 Posts

Posted - 2007-06-15 : 07:15:55
I failed to mention that the query has to return c1,c2 for the max date in c3
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-06-15 : 08:27:49
see: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=85052

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -