从sql中按日期选择最新记录 [英] Select latest record by date from sql

查看:739
本文介绍了从sql中按日期选择最新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据给定的ID选择表格中输入的最新记录。



例如



ID记录日期

1 abc 01-02-2013

1 def 02-02-2013

1 ghi 03-02- 2013



我想选择日期是03-02-2013的最新记录。

从表中选择*  其中 Id = ' 一些id'和Date = 

解决方案

尝试:

  SELECT   TOP   1  *  FROM  MyTable  WHERE  id =  某些ID'  ORDER   BY  [日期]  DESC  


I want to select the latest record enter in the table with respect to given id.

e.g

ID Record Date
1 abc 01-02-2013
1 def 02-02-2013
1 ghi 03-02-2013

I want to select record where Date is 03-02-2013 its the latest one.

Select * from Table where Id='Some id' and Date=

解决方案

Try:

SELECT TOP 1 * FROM MyTable WHERE id='Some id' ORDER BY [Date] DESC


这篇关于从sql中按日期选择最新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆