I have the below table, named shop:
Can you suggest the query to have no duplicate "product" results associated with the most recent delivery date.
Thanks
I have the below table, named shop:
Can you suggest the query to have no duplicate "product" results associated with the most recent delivery date.
Thanks
SELECT
product,
MAX(delivery_date) as most_recent_delivery_date
FROM table_name
GROUP BY product;
If you want just the product, you can use aggregation as in the other answers. If you want the complete row, then one method is:
select t.*
from (select t.*,
row_number() over (partition by product order by delivery_date desc) as seqnum
from t
) t
where seqnum = 1;