SELECT *
FROM VIEW_GOODSSTORE a
WHERE EXISTS ( SELECT 1
FROM ( SELECT MAX(billdate) billdate ,
goodsid
FROM VIEW_GOODSSTORE
GROUP BY goodsid
) b
WHERE a.billdate = b.billdate
AND a.goodsid = b.goodsid )
------其他解决方案-------------------- select * from VIEW_GOODSSTORE a
where not exsits(select 1 from VIEW_GOODSSTORE where goodsid=a.goodsid and billdate>a.billdate) ------其他解决方案-------------------- SELECT goodsid,max(billdate),max(STOREID),max(STORESTATEID)
from VIEW_GOODSSTORE
group by goodsid