Rohan Nayani Rohan Nayani - 11 days ago 5
SQL Question

Maximum date row postgresql

I want to find out a rows which have maximum date by product,

click to see table

I want to find out a maximum date of rows by product_id

click here to see what i want

I have tried a DISTINCT but can't succeed!

Answer
select * from (
   SELECT *, row_number() over (partition by Product_ID order by date desc) r 
   FROM table 
) T
WHERE T.r=1
Comments