I want to make a query that returns the most recent sales order for a customer.
I have a Customers and and an Orders table that are joined on ID, and i’ve made the following query to return all values. Can anyone help me modify it to only return the latest value for each ID? Orders.created_at is formatted like so yyyy-MM-dd HH:mm:ss
SELECT Customers.ID, Customers.Name, Customers."Sales Responsible US", Customers."Sales Responsible", Customers."Website", ISNULL(Orders.row_invoiced, '-1'), Orders.status, Orders.created_at
FROM "Customers"
LEFT JOIN Orders
On Customers.ID=Orders.customer_id
Try this ::