Posts
1150
Comments
891
Trackbacks
1
T-SQL: Select where date = max

select t.column1, t.column2, t.column3, t.date from table t with (nolock) where t.column2 like '%AAA%'
and t.date = (select max(date) from table where column2 = t.column2)
order by t.column2

posted on Friday, October 14, 2005 2:31 PM Print
Comments
Gravatar
# Mr
Jean-Pierre Schnyder
3/23/2013 9:56 AM
stating the request as

select column1, column2, column3, date from table where column2 like '%AAA%'
and date = (select max(date) from table t where t.column2 = column2)

is two order of magnitude more efficient in MySql as placing the table t in the main select. I do not have any explanation !

Jean-Pierre

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 5 and 5 and type the answer here: