Results 1 to 3 of 3
  1. #1
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29

    Query Subtotal

    I'm developing a payroll database and having a lot of trouble creating a query to determine the total bill for each project (obviously an important part). Each of the [Bill#] entries in the query is associated with a specific survey code [Line#Code]. I need a query to sum all of the [Bill#] entries that have the same survey code. I'm having difficulty figuring out how to relate all of the separate [Line#Code] field values to one survey code. I've looked at UNION queries but haven't had any success so far.

    This is the SQL of the query that has all the information the new query should need. I need the report display something like this:



    Survey Code: Total Bill:
    0500 $10,253.50
    0550 $15,234.33

    etc.

    SELECT AllElapsedTimes.Line1Code, AllElapsedTimes.Line2Code, AllElapsedTimes.Line3Code, AllElapsedTimes.Line4Code, AllElapsedTimes.Line5Code, AllElapsedTimes.Line6Code, AllElapsedTimes.Line7Code, AllElapsedTimes.Line8Code, AllElapsedTimes.Bill1, AllElapsedTimes.Bill2, AllElapsedTimes.Bill3, AllElapsedTimes.Bill4, AllElapsedTimes.Bill5, AllElapsedTimes.Bill6, AllElapsedTimes.Bill7, AllElapsedTimes.Bill8
    FROM AllElapsedTimes, [Survey Codes]
    GROUP BY AllElapsedTimes.Line1Code, AllElapsedTimes.Line2Code, AllElapsedTimes.Line3Code, AllElapsedTimes.Line4Code, AllElapsedTimes.Line5Code, AllElapsedTimes.Line6Code, AllElapsedTimes.Line7Code, AllElapsedTimes.Line8Code, AllElapsedTimes.Bill1, AllElapsedTimes.Bill2, AllElapsedTimes.Bill3, AllElapsedTimes.Bill4, AllElapsedTimes.Bill5, AllElapsedTimes.Bill6, AllElapsedTimes.Bill7, AllElapsedTimes.Bill8;

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Appears your data is not normalized. Use UNION query to rearrange data into normalized structure.

    Use that query in subsequent queries.

    Post example of data from the two tables.

    Advise no spaces in naming convention.
    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.

  3. #3
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29
    Thank you. I have thankfully figured out the issue. It was mostly a matter adjusting the relationship details. I appreciate the help!

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

Similar Threads

  1. Use a subtotal and %total
    By finlain in forum Programming
    Replies: 1
    Last Post: 03-28-2013, 09:36 AM
  2. Create Subtotal in Access 2010 Query
    By alcharbonneau in forum Queries
    Replies: 8
    Last Post: 03-13-2013, 12:52 PM
  3. Subtotal on Query
    By claysea in forum Queries
    Replies: 1
    Last Post: 02-17-2012, 10:56 AM
  4. Replies: 1
    Last Post: 02-13-2012, 04:58 PM
  5. Subtotal
    By abc in forum Access
    Replies: 3
    Last Post: 01-31-2011, 04:47 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