How to Fetch MAX Date Records from a Table
select p1.ProductId,p1.Price,p1.LastUpdate
from Product p1
inner join (select productid, max(LastUpdate) max_date
from Product
group by ProductId) p2
on p1.ProductId=p2.ProductId and p1.LastUpdate=p2.max_date;
No comments:
Post a Comment