当前位置: 代码迷 >> PB >> 符合条件的最小记录解决方案
  详细解决方案

符合条件的最小记录解决方案

热度:10   发布时间:2016-04-29 08:34:37.0
符合条件的最小记录
想查找符合qfno='100101' 条件, 且日期whdate为最小的记录,但用下面语句
SELECT * FROM SEAL where qfno='100101' and whdate in (select min(whdate) from seal )
出现日期为库内最小才查得出来,不知道哪里错误,请高手指教。

------解决方案--------------------
SQL code
SELECT a.* FROM SEAL awhere a.qfno='100101' and a.whdate in (select min(whdate) from seal where qfno =a.qfno )
------解决方案--------------------
SQL code
select top 1 * from seal where qfno = '100101' order by whdate asc
  相关解决方案