I want to Retrieve customer names, total orders (how many time they order the products) and the total amount they're spent in the lifetime. Run a single query WITHOUT
having operators. Show only customers who have at least one order.
Here is my database
Customer- CustomerID| CustomerName SalesOrder- SalesOrderID | CustomerID | SaleTotal 100000 | John 1001 | 100000 | 2000 200000 | Jane 1002 | 100000 | 3000 300000 | Sean 1003 | 200000 | 5000
When I query
SELECT CustomerName,count(*) AS Total_Orders,sum(SaleTotal) AS SaleTotal FROM Customer C,SalesOrderHeader SH WHERE C.CustomerID=SH.CustomerID;
It show only one row. The answer that I want is
CustomerName | Total_Orders | SaleTotal John 2 5000 Jane 1 5000
I just new on mysql. So does anyone here know how to do this?