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

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

1 Expert Approved Answer
Step: 1 Unlock

The detailed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!