SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

240 Posts

Posted - 09/28/2012 :  13:45:16  Show Profile  Reply with Quote
Hi All,

I am having two tables T1 and T2

T1 is having Student_Id and Last_Exam_Date

T2 is having Student_Id and Exam_Date

Now i have to update T1 table with last Exam Date. Please suggest

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 09/28/2012 :  16:13:05  Show Profile  Reply with Quote
sounds like this

SET t1.Last_Exam_Date = t2.MaxDate
FROM T1 t1
INNER JOIN (SELECT Student_Id,MAX(Exam_Date) AS MaxDate
            FROM T2
            GROUP BY Student_id
ON t2.Student_Id = t1.Student_Id

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000