Results 1 to 2 of 2
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to add running total column to a query

    I have the following query:

    SELECT Count(tblEmployee.id) AS [Count], tbllocal.ID AS LID, tbllocal.local_cd AS LCD, tbllocal.local_name AS LDE
    FROM tblEmployee LEFT JOIN tbllocal ON tblEmployee.local_id = tbllocal.ID
    GROUP BY tbllocal.ID, tbllocal.local_cd, tbllocal.local_name
    ORDER BY tbllocal.local_name;

    It displays the following:

    Code:
    Count   LID LCD LDE
    2719 
    1       16  105    Local 158
    1216    1   17  Local 17
    528     5   17  Local 17
    1       2   463 Local 463
    1       13  841 Local 841
    How do I add a 5th column Run Count that shows running total of the Count column?

    Run Count
    2719
    2720
    3936
    4464
    4465
    4466

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    What is tbllocal.ID and tbllocal.local_cd.

    Where does the line showing only 2719 come from?

    One way would be to populate a table with the above, then calculate that column into a new field, then query that table.
    Last edited by patt; 2015-09-03 at 07:03.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •