Results 1 to 5 of 5
  1. #1
    hackhack is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2016
    Posts
    3

    Post Group By Total

    Hi Team,


    This is my first post.

    I have table as

    Item1 Item2 Item3 Item1Qty Item2Qty Item2Qty
    1 2 3 8 6 10
    4 1 5 9 9 23
    7 1 5 69 26 51

    Now I want a report in this format

    Item Qty(Sum Item Qty)
    1 86
    2 6
    3 10
    5 74


    Thank in Advance

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Your table design doesn't look normalized in the least. Suggest you review database normalization before you go too far, otherwise everything you want to get out of it will likely be a real chore. The 1,4 and 7 in the item1 field don't make any sense to me either. You want item 5 total of 74, yet you have no item field for this, so the numbers don't make much sense. However, that's of little consequence; the lack of normalization is much more important. To get any advice on this from the forum, I think you'll have to supply more information about what you're doing, but if you review the subject first, you will be able to ask better questions thus get better advice.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    hackhack is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2016
    Posts
    3
    Quote Originally Posted by Micron View Post
    Your table design doesn't look normalized in the least. Suggest you review database normalization before you go too far, otherwise everything you want to get out of it will likely be a real chore. The 1,4 and 7 in the item1 field don't make any sense to me either. You want item 5 total of 74, yet you have no item field for this, so the numbers don't make much sense. However, that's of little consequence; the lack of normalization is much more important. To get any advice on this from the forum, I think you'll have to supply more information about what you're doing, but if you review the subject first, you will be able to ask better questions thus get better advice.
    Thanks for the reply.These tables are create long back and I cannot change this as this contains huge amount of Data.



    1 = 86 is the sum of item 1


    So in the table


    Item1 Item2 Item3 Item1Qty Item2Qty Item2Qty
    1 8
    1 9
    1 26
    Highlighted in Bold(Sum of Highlighted Items)

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    8 + 9 + 26 = 43

    8 + 9 + 69 = 86

    I presume the second Item2Qty should be Item3Qty. Why did you exclude items 4 and 7 from the totals example?

    I agree with micron. Data structure is a mess. However, messes can be dealt with, not always simple but can be done. Consider:

    Query1:

    SELECT 1 AS Source, Item1 AS ItemNum, Item1Qty AS Qty FROM tablename
    UNION SELECT 2, Item2, Item2Qty FROM tablename
    UNION SELECT 3, Item3, Item3Qty FROM tablename;

    Query2:

    SELECT ItemNum, Sum(Qty) AS SumQty FROM Query1 GROUP BY ItemNum;


    The UNION query rearranges the data into normalized structure should have been to begin with. There is no builder or wizard for UNION query. Must type or copy/paste in query SQL View. Limit of 50 SELECT lines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    hackhack is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2016
    Posts
    3
    Quote Originally Posted by June7 View Post
    8 + 9 + 26 = 43

    8 + 9 + 69 = 86

    I presume the second Item2Qty should be Item3Qty. Why did you exclude items 4 and 7 from the totals example?

    I agree with micron. Data structure is a mess. However, messes can be dealt with, not always simple but can be done. Consider:

    Query1:

    SELECT 1 AS Source, Item1 AS ItemNum, Item1Qty AS Qty FROM tablename
    UNION SELECT 2, Item2, Item2Qty FROM tablename
    UNION SELECT 3, Item3, Item3Qty FROM tablename;

    Query2:

    SELECT ItemNum, Sum(Qty) AS SumQty FROM Query1 GROUP BY ItemNum;


    The UNION query rearranges the data into normalized structure should have been to begin with. There is no builder or wizard for UNION query. Must type or copy/paste in query SQL View. Limit of 50 SELECT lines.


    Thanks for the reply. I will check.

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

Similar Threads

  1. DSUM Running total by group
    By chowing0823 in forum Access
    Replies: 10
    Last Post: 10-07-2022, 03:15 AM
  2. Summing group total of mileage
    By gemadan96 in forum Reports
    Replies: 1
    Last Post: 07-05-2014, 10:12 AM
  3. Replies: 7
    Last Post: 05-06-2013, 02:39 PM
  4. Group by Level2 BUT Total by Level3
    By goodguy in forum Reports
    Replies: 3
    Last Post: 10-05-2011, 08:54 AM
  5. not correct running total in group
    By cmk in forum Reports
    Replies: 1
    Last Post: 12-06-2006, 05:56 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