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
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Posted Nov 2, 2008, 11:36 PM EST
Instead of looping you can use the "group by" clause with sum aggregate function.
Looping concept is time consuming process.