日期:2014-05-18 浏览次数:20561 次
select t.* from tb t where ordernumber = 10 and id = (select min(id) from tb where organ = t.organ and branch = t.branch and ordernumber = 10) select t.* from tb t where ordernumber = 10 and id = (select max(id) from tb where organ = t.organ and branch = t.branch and ordernumber = 10) select t.* from tb t where ordernumber = 10 and not exists (select 1 from tb where organ = t.organ and branch = t.branch and ordernumber = 10 and id < t.id) select t.* from tb t where ordernumber = 10 and not exists (select 1 from tb where organ = t.organ and branch = t.branch and ordernumber = 10 and id > t.id)
------解决方案--------------------
select * from tb t where ordernumber = 10 and id = (select max(id) from tb where organ=t.organ and branch=t.branch and ordernumber=10)
------解决方案--------------------