database loop through
Geeks,
I want to create a report from a db, showing the sale amount that each employee makes each week.(2 tables: employee, sales)
Please help me with the concept or code structure or samples...What I am thinking is:
1. Move employee Name + ID into a dataset
2. Loop through the "sales" table to calculate the total sales for each employee (based on ID)
3. Store Name + TotalSale in a temp array
4. Loop through a temp array to write a report on the screen.
Is this logic efficient? Please advice.
Thanks
--------------------------------
From: Kenneth Nguyen
Posted Nov 3, 2008, 4:36 AM
Instead of looping you can use the "group by" clause with sum aggregate function.
Looping concept is time consuming process.