You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
342 B
SQL

/*Write a SQL statement to make a report with customer ID in such a manner that, the largest number of orders booked by the
customer will come first along with their highest purchase amount.*/
SELECT customer_id, COUNT(DISTINCT ord_no),
MAX(purch_amt)
FROM orders
GROUP BY customer_id
ORDER BY 2 DESC;