MAX()
function within a subquery to select the latest order_date
for each product_id
from the Orders
table.JOIN
operation between the Products
table and the Orders
table on the product_id
column to get all the necessary details for the final output.product_id
and order_date
to filter only the most recent orders for each product.product_name
, product_id
, and order_id
in ascending order to meet the output requirements.erDiagram Customers { int customer_id varchar name } Orders { int order_id date order_date int customer_id int product_id } Products { int product_id varchar product_name int price } Customers ||--o{ Orders : "" Products ||--o{ Orders : ""