running sum

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi; all
I have a table with four fields:
Fields: name month days monthlysalary
Records: jack 1 15 10000
jack 2 30
20000
jim 1 3
10000
jim 2 30
20000
I want to get the sum of salary for 15 days of month 1 and 30 days of month
2 for jack that results 25000 . (15/30 days*10000+30/30 days*20000)
For jim 3 days of month 1 and 30 days of month 2 that results 21000 . (3/30
days*10000+30/30 days*20000)
How can I do through VBA?
thanks for help
 
Why VBA when a query can do it?

SELECT Table1.empname, Sum([workdays]*[salary]/30) AS earned
FROM Table1
GROUP BY Table1.empname;

I have not put in any where clauses to restrict the months to 1 and 2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top