Results 1 to 2 of 2

Thread: Running Total

  1. #1
    Join Date
    Dec 2008
    Posts
    2

    Unanswered: Running Total

    I am trying to total 3 different Running totals. Is this possible?

    Here is an example of what I am trying to do. Let's say that there is a grouping on a job no 100 where I am totaling parts for that job. I have a running total on Part X, Part Y, Part Z. Is there a way to add up all of these parts? My problem is when one part isn't used for that job. It doesn't give me a total then.

  2. #2
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    Please always say what version you are using. In 2005 use CUBE/ROLLUP. In 2008 use GROUPING SETS.

    SELECT JobNo, PartNo, SUM(Quantity) Quantity
    FROM Stock
    GROUP BY PartNo,JobNo WITH ROLLUP;

    SELECT JobNo, PartNo, SUM(Quantity) Quantity
    FROM Stock
    GROUP BY GROUPING SETS ((JobNo,PartNo),(PartNo),());

Posting Permissions

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