Results 1 to 5 of 5
  1. #1
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31

    Question How to do Sum of Sums in Query


    Hello All,

    I have a table with CityID and Schools Register with City i.e.

    CityID SchoolRegister
    Hyd
    5
    Karachi 10
    Hyd
    20
    Karachi 10

    I have put a query in this table:Enrollment

    Field: CityID SchoolRegister
    Table: Enrollment Enrollment
    Total: Group By Sum

    The result of it is:

    CityID SchoolRegister
    Hyd 25
    Karachi 20


    I would like to have a Third column what will automatically do sum of School Register which is 45,

    In the Third Column of Query, I click on Expression Builder and typed TotalSum: [schoolregister] but it is summing up
    all Hyd and Karachi Schools not summing the sum of total schools.


    I will appreciate your help please.

    Thanks

    Many regards

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    In design mode, change the TotalSum to TotalSum: DSum("SchoolRegister","Enrollment")

  3. #3
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31

    Question

    Hi,

    Thanks for your reply, Yes its summing up all the Schools Register in Total Sum Column, but the sum is appearing in each row: i.e.

    CityID SchoolRegister TotalSum
    Hyd 25 45
    Karachi 20 45

    I would like to have only one sum in TotalSum Column if possible.


    Thanks


    Many regards

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Is this the output you are looking for?


    CityID SchoolRegister
    Hyd 25
    Karachi 20
    TotalSum 45

    If that is the case, you have to use the UNION to create the "TotalSum" Record.

    SELECT Enrollment.CityID, Sum(Enrollment.SchoolRegister) AS SumOfSchoolRegister
    FROM Enrollment
    GROUP BY Enrollment.CityID
    UNION
    SELECT "TotalSum", Sum(Enrollment.SchoolRegister) AS SumOfSchoolRegister
    FROM Enrollment;

  5. #5
    braveali is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    31
    Thanks a million... Its solved with your guidance

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query help with Sums
    By dhogan444 in forum Queries
    Replies: 1
    Last Post: 08-10-2012, 02:19 PM
  2. Query that sums data
    By accessnovice78 in forum Queries
    Replies: 3
    Last Post: 04-12-2012, 11:46 AM
  3. Replies: 1
    Last Post: 03-23-2012, 09:45 AM
  4. Query that sums a field based on 2 tables
    By scratchmb in forum Queries
    Replies: 6
    Last Post: 03-18-2012, 08:31 PM
  5. query that sums the data for me
    By citygov in forum Queries
    Replies: 4
    Last Post: 08-18-2011, 03:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums