Hi Luis,
Basicly you'll have to create running total on the total sales on the list of cutomers ordered by the total sales in descendibg oreder. That you can use that totals to cut the records after 80% is reached.
>I solved that part, it was easier than I thought. In fact, I didn't have to create a cursor. I even did the same thing for other purposes. Well, the fact is that I need to create a Crystal report that shows me the, for example, 80% of customers that make my monthly sales. I already have a SELECT that gets me the customers, the total sales for that month, and the % that that customers is. In other words, percentage is not based on number of customers but on number of customers that make that 80%. Since this was more or less complex I created a stored procedure so that it returns a cursor for Crystal Reports.
>
--sb--