Obtain the last Inserted record of a group of same ID's
So, i have this structure:
IDSale DateInserted
1 20开发者_开发知识库11-1-12
1 2011-1-13
1 2011-1-10
2 2011-1-12
2 2011-1-15
2 2011-1-11
The result of my question would be:
IDSale DateInserted
1 2011-1-13
2 2011-1-15
How can I achieve this in a MYSQL Query. I can do this programatically, but
Well, for this particular case, the following will do the trick:
SELECT IDSale, MAX(DateInserted) DateInserted
FROM tablename
GROUP BY IDSale
精彩评论