| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
Stuck with a query questionHello there
I would appreciate any help on this I have written a query that lists the customers and their total spending from different orders. ex. Customers.......TotalSpending Cust.1............$2300 Cust.2............$1100 etc.................etc... However, I need to find the size of the minimal set of customers whose total value is over 80% of the total value of all customers. value of a customer = total of his/her spending. total value of all customers = (SELECT sum(TotalSpending) FROM CustomerValues) Thanks |
|
|||
|
Customers.......TotalSpending
Cust.1............$2300 Cust.2............$1100 etc.................etc... select customers , TotalSpending from CustomerValues where TotalSpending > (select 0.8* sum(TotalSpending) from customerValues); |
![]() |
| Thread Tools | Search this Thread |
|
|