Limiting a mysql result

Mar 12, 2012   //   by phpfreelancer.biz   //   Blog, MySQL Tutorial  //  No Comments

I am trying to write a SQL statement to return the latest record for each subject for a person


Here’s the Code:

Select t1.Name,t1.Subject,t1.Grade
From SomeTableName t1
inner join (Select Name,Subject,Max(Counter) As Counter 
            From SomeTable 
            Group By Name,Subject) t2
On t1.counter = t2.counter

Leave a comment

Share This Post

RSS Wordpress News