Sum of values of a field (1 Viewer)

Waheed2008

Registered User.
Local time
Today, 11:26
Joined
Jul 17, 2008
Messages
57
I have a table Table1 having the fields
ID, Department, Expense, etc.

Each department has many expenses that are listed in this table. I want to make a query such that all the fields of Table1 are there AND an additional field should be placed into query such that it shows total expense of that department of record. The query result should be like this:

ID, Department, Expense, Total Expense, etc.

For example if there is record of Dept1, the Total Expense of Dept 1 should be displayed in this field.

How should I do that? can any budy help me ?

Thanks
 

Brianwarnock

Retired
Local time
Today, 08:26
Joined
Jun 2, 2003
Messages
12,701
You can do this by having a totals query grouping on dept and summing expenses and then joining it back to the table on dept, but it makes no sense to show the same total expenses on each individual record.

Brian
 

Rabbie

Super Moderator
Local time
Today, 08:26
Joined
Jul 10, 2007
Messages
5,906
I have a table Table1 having the fields
ID, Department, Expense, etc.

Each department has many expenses that are listed in this table. I want to make a query such that all the fields of Table1 are there AND an additional field should be placed into query such that it shows total expense of that department of record. The query result should be like this:

ID, Department, Expense, Total Expense, etc.

For example if there is record of Dept1, the Total Expense of Dept 1 should be displayed in this field.

How should I do that? can any budy help me ?

Thanks
Try something like this
Code:
SELECT DISTINCTROW Table1.Department, Sum(Table.Expense) AS [Sum Of Expense]
FROM Table1 GROUP BY Table1.Department ;
This should give you the total expenses for each department
 

Waheed2008

Registered User.
Local time
Today, 11:26
Joined
Jul 17, 2008
Messages
57
I am realy very sorry that I cannot understand both of solutions. I am new to access and have started work on it recently.

The situation I mentioned is an example. I shall adjust the solution into my actual project (that is little bit complecated). I am attaching the sample file.

Brianwarnok's solution is seems to be easy, but still I cannot understand what to do exactly.

Rabbie said to put query. Can you tel me where to put this query :confused:

I know that these are a little bit silly questions, but ...

Thanks
 

Attachments

  • db1.zip
    6.8 KB · Views: 65

Brianwarnock

Retired
Local time
Today, 08:26
Joined
Jun 2, 2003
Messages
12,701
See Attached

Brian
 

Attachments

  • db1waheedbjw.zip
    8.6 KB · Views: 85

Waheed2008

Registered User.
Local time
Today, 11:26
Joined
Jul 17, 2008
Messages
57
Thank you very much
It works and I have fitted this method into my project.
Thanks Brianwarnok!
God bless you...
 

Users who are viewing this thread

Top Bottom