开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜