Results 1 to 4 of 4
  1. #1
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    Need to modify query to total sum for cost and service charge

    Here is the query
    SELECT DISTINCTROW Transations.TransationID, Transations.CompanyID, Transations.EmployeeID, Transations.LocationID, DateDiff("d",[Date],Date()) AS CheckToday, Transations.Date, Transations.Time, Transations.Type, Transations.Cost, Transations.[Service Charge], Nz([Service Charge])+Nz([Cost]) AS PayAmount, Nz([Cost]) AS CostAmount
    FROM Transations
    GROUP BY Transations.TransationID, Transations.CompanyID, Transations.EmployeeID, Transations.LocationID, DateDiff("d",[Date],Date()), Transations.Date, Transations.Time, Transations.Type, Transations.Cost, Transations.[Service Charge], Nz([Service Charge])+Nz([Cost]), Nz([Cost])
    HAVING (((Transations.LocationID)=1) AND ((DateDiff("d",[Date],Date()))=0) AND ((Transations.Type)<>"PAYMENT"));




    I need to get a total sum for Cost and Service Charge. How do I modify the query to accomplish this. Should I attempt to do this in VBA code instead?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't see benefit to DISTINCTROW and GROUP BY in the same query.

    Build another query use the posted query as source and use Sum() function.

    or

    Use posted query as the RecordSource of a report and do summary calcs in report Header/Footer sections.
    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
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37
    Here was the query
    I need to sum the cost and service charge columns. I am not familiar enough with SQL to do what you suggested. See graphic enclosure

    http://www.swdev.biz/query.png

  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
    52,929
    Use the Access query builder. A query can be used just like a table to build another query. What exactly about my suggestions do you not understand?
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-18-2015, 06:05 PM
  2. Replies: 5
    Last Post: 08-11-2014, 10:08 AM
  3. Total charge , creating a query
    By lasts3cond in forum Queries
    Replies: 1
    Last Post: 12-03-2013, 04:57 PM
  4. Most recent cost query
    By nigelbloomy in forum Queries
    Replies: 9
    Last Post: 07-12-2012, 02:41 PM
  5. Service to Cost by Quarter HELP!!!
    By campanellisj in forum Database Design
    Replies: 5
    Last Post: 09-26-2010, 06:58 AM

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