想取相同名称的记录中最近的一条
如下所示的数据:
id name change_date order_no
1 电话 2012-12-10 0001
2 电脑 2012-12-10 0002
3 电灯 2012-12-10 0003
4 电话 2012-12-20 0004
5 电脑 2012-12-20 0005
6 电灯 2012-12-20 0006
==========================================
现在想要通过日期change_date字段找出2012-12-21前的最近一条电脑的记录。
请问SELECT查询语句怎么写?
select * from table where change_date<='2012-12-21' and name='电脑'
用这SQL语句查询出来有两条记录,我只想要order_no为005的这条记录。不知这个SQL语句怎么写?请高手帮忙!