SQL 复杂查询

近期碰到需要取日期最小的不同条件记录的问题,请各位xdjm赐教!! 
http://bbs.csdn.net/topics/330146169
表a:

表a: 
序号  材料 数量  入库日期  
1      A  8    2009-12-1 
2      A  9    2009-12-5 
3      B  12    2009-11-18 
4      B  10    2009-11-19 
5      C  5    2009-10-9 
6      C  13    2009-11-8 

想要的结果为: 

序号  材料 数量  入库日期  
1      A  8    2009-12-1 
3      B  12    2009-11-18 
5      C  5    2009-10-9 
select *
from tb t 
where not exists(select 1 from tb where 材料=t.材料 and 入库日期<t.入库日期)
select * from tb a where not exists(select 1 from tb where  材料=a.材料 and 入库日期<a.入库日期  ) 
select *
from tb t
where not exists(select 1 from 材料=t.材料 and 日期<t.日期)
原文地址:https://www.cnblogs.com/canyangfeixue/p/3242599.html