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

符合条件的最小记要

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

------解决方案--------------------
select top 1 * from seal where qfno = '100101' order by whdate asc
  相关解决方案