select * from tb a where not exists (select 1 from tb where Peoid=a.Peoid and Date>a.Date)
在 Northwind 这两个语句返回的行数不一样select CustomerID,max(OrderDate) from orders group by CustomerIDselect * from orders a where not exists(select 1 from orders where CustomerID=a.CustomerID and OrderDate>a.OrderDate) order by CustomerID
select peoid,max(date) from 表 group by peoid
select peoid,max(date) from 表 group by peoid
select peoid,max(date) from 表 group by peoid
select * from tb a where (select count(1) from tb where Peoid=a.Peoid and Date>=a.Date)<1
select a.* from table a, (select PeoID,Max(date) as date from table group by PeoID ) b where a.PeoID = b.PeoID and a.date = b.date order by a.id
SELECT PeoID,max(date) as date from table group by PeoID
and Date>a.Date)
这两个语句返回的行数不一样select CustomerID,max(OrderDate) from orders group by CustomerIDselect * from orders a where not exists(select 1 from orders where CustomerID=a.CustomerID and OrderDate>a.OrderDate)
order by CustomerID
and Date>=a.Date)<1
from table a,
(select PeoID,Max(date) as date
from table
group by PeoID
) b
where a.PeoID = b.PeoID
and a.date = b.date
order by a.id
select a.*
from table a,
(select PeoID,Max(date) as date
from table
group by PeoID
) b
where a.PeoID = b.PeoID
and a.date = b.date
order by a.id
上述應該才是樓主要的!!!!!