Rohan Nayani Rohan Nayani - 1 year ago 150
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 Source
select * from (
   SELECT *, row_number() over (partition by Product_ID order by date desc) r 
   FROM table 
) T
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download