This is my relational schema
From all the sales orders, I need to find the one with the highest total spent by a customer and to find the name of that customer.
I really don't know how to come up with a solution to this.
Finding the order with the highest total is not difficult:
sales_order.customer_id = customer_customer_id
SELECT MAX(total), customer_id
GROUP BY customer_id
I would probably go about this with a subquery in my where clause like so:
SELECT c.Name FROM sales_order o INNER JOIN Customer c ON c.Customer_ID = o.Customer_ID WHERE Total = (SELECT MAX(Total) FROM sales_order)