Question: Write a SQL query to find the total number of orders made by each customer, sorted in descending order by the total number of

Write a SQL query to find the total number of orders made by each customer, sorted in descending order by the total number of orders. Example: Input: Order table: order_id 1 2 3 4 5 6 Output: customer_id 2 3 1 Query: customer_id 1 2 1 3 2 3 total_orders 22 19 2 SELECT customer_id, COUNT(*) AS total_orders FROM Order GROUP BY customer_id ORDER BY total_orders DESC Copy code
Step by Step Solution
3.48 Rating (155 Votes )
There are 3 Steps involved in it
The detailed ... View full answer
Get step-by-step solutions from verified subject matter experts
