I have an typical CUSTOMER/ORDERS set of tables and I want to display the total percentage of sales a particular customer is responsible for. I can get the total number of orders in the system like so:
SELECT COUNT(order_id) FROM orders
And I can get the the total number of orders made by the customer like so:
SELECT COUNT(order_id) FROM orders WHERE cust_id = 541
How can I combine these into a single query that returns the percentage of sales for a particular customer? Thanks!