Tables in the database
Customers:
cust_id number(10)|cust_name varchar2(50)|email varchar2(50)|order_sum varchar2(50)|id_firms number(10) Firms:
f_name varchar2(50)|f_id number(10)|itme_cooperation timestamp|email varchar2(50) Orders:
order_id number(10)|order_sum number(10)|oder_date timestamp|customers_id number(10) I need to choose customers with the sum of their orders and the names of the companies for which the most orders were made. This can be obtained only through customers.id_firms, as far as I understand.
That's how I display the names of customers (customers) and the amount of their orders.
select customers.CUST_NAME, sum(orders.order_sum) sum_of_orders from customers, orders group by customers.CUST_NAME,customers.CUST_ID, orders.customers_id having customers.CUST_ID = orders.CUSTOMERS_ID ORDER BY customers.CUST_NAME; But how can we also add a sample of the maximum number of customers - firms' links here, to show for which firms this customer has the largest number of orders?
The result should be:
ΠΠΌΠ΅Π½Π° ΡΠΈΡΠΌ | ΠΠΌΠ΅Π½Π° Π·Π°ΠΊΠ°Π·ΡΠΈΠΊΠΎΠ² | Π‘ΡΠΌΠΌΠ° Π·Π°ΠΊΠ°Π·ΠΎΠ² (ΠΎΠ±ΡΠ°Ρ Π΄Π»Ρ Π·Π°ΠΊΠ°Π·ΡΠΈΠΊΠ°, Π° Π½Π΅ Π΄Π»Ρ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΉ ΡΠΈΡΠΌΡ Π² ΠΏΠ΅ΡΠ²ΠΎΠΌ ΡΡΠΎΠ»Π±ΡΠ΅)