物料编码 所在工位 加工日期
0001 a 20100701
0001 b 20100702
见上表,数据很多,想得到某个编码的最后加工日期的这一行的数据(要包含所在工位)。谢谢!select 物料编码,所在工位,max(加工日期) from table1 group by 物料编码,所在工位,加工日期
这样不行,会把所有的日期都列出来。但是如果select 物料编码,max(加工日期) from table1 group by 物料编码,加工日期
又不能列出所在工位列。谢谢!
0001 a 20100701
0001 b 20100702
见上表,数据很多,想得到某个编码的最后加工日期的这一行的数据(要包含所在工位)。谢谢!select 物料编码,所在工位,max(加工日期) from table1 group by 物料编码,所在工位,加工日期
这样不行,会把所有的日期都列出来。但是如果select 物料编码,max(加工日期) from table1 group by 物料编码,加工日期
又不能列出所在工位列。谢谢!
where (select coung(*) from tb where t.物料编码=物料编码 and t.加工日期<加工日期)<1
http://blog.csdn.net/xys_777/archive/2010/07/03/5711128.aspx
select * from tb a
where not exists(select 1 from tb and 物料编码=a.物料编码 and 加工日期 > a.加工日期 )