2009 Dec 16 4:31 PM
Moderator message: pleause use a meaningful subject in future
Hi,
I have a custom table which has customer ID field and amount field.
In the report I need to bucket data by amount and no. of customers in that bucket.
For ex: for amount range 1.00 u2013 25.00 there are 100 customers and total amount $1000.00, 25.01 to 50.00 there are 34 customers and total amount $20,000 and so on.
What I am planning to do is fetch records from table into internal table using group by clause,
SELECT CUSTOMER AMOUNT FROM CUSTOMER_FINES INTO TABLE LT_FINES GROUP BY CUSTOMER AMOUNT.
This would bring me in the internal table all customers and their fine. Now what would be the best logic to separate them out into groups.
Approach what I thought of is having two variables for each bucket no_of_customers and total_amount. Then loop through the internal table add If conditions on amount and then accordingly increment no_of_customers for that bucket and add amount to total_amount.
But the internal table is likely to have a lot of records about half a million. Is this a good approach. Can you'll recommend what is the right way to achieve this.
Thanks in advance,
CD
Edited by: Matt on Dec 17, 2009 10:02 AM
Moderator message: pleause use a meaningful subject in future
Hi,
I have a custom table which has customer ID field and amount field.
In the report I need to bucket data by amount and no. of customers in that bucket.
For ex: for amount range 1.00 u2013 25.00 there are 100 customers and total amount $1000.00, 25.01 to 50.00 there are 34 customers and total amount $20,000 and so on.
What I am planning to do is fetch records from table into internal table using group by clause,
SELECT CUSTOMER AMOUNT FROM CUSTOMER_FINES INTO TABLE LT_FINES GROUP BY CUSTOMER AMOUNT.
This would bring me in the internal table all customers and their fine. Now what would be the best logic to separate them out into groups.
Approach what I thought of is having two variables for each bucket no_of_customers and total_amount. Then loop through the internal table add If conditions on amount and then accordingly increment no_of_customers for that bucket and add amount to total_amount.
But the internal table is likely to have a lot of records about half a million. Is this a good approach. Can you'll recommend what is the right way to achieve this.
Thanks in advance,
CD
Edited by: Matt on Dec 17, 2009 10:02 AM
2009 Dec 16 8:08 PM
Hi,
do this.
1. create counters for the no of ranges you have say 1.00 u2013 25.00 counter1 total_amt1, 25.01 to 50.00 counter2 total_amt2 etc
2. loop at your internal table
3. check which range the amount falls into using IF statement
4. increment counter* by 1 and add amount to total_amt*
You are done.
Regards
Prasenjit
2009 Dec 17 9:03 AM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |