I have a new question based on this two tables:
1. IN_Order(price, order_amount, order_date, BENR(FK), BANR(FK)
2. Product (Product_name, product_price, BANR(PK)
The question i will answer is: Which product sales best and how much?
For answer this question I need to use 2 rows; Product_name and order_amount.
I think the best way to solve the question is with sum() function and function for max().
I´d tried this code:
Select product_name, sum(order_amount) from Product p, IN_Order i WHERE order_amount = (select max(order_amount from in_order) AND i.banr=p.banr;
Results: Products sold most at one time. This is not the right answar.
What should I do to answer my question?