Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    combining 2 queries

    Hi Guys



    I have two queries that I would like to add together, the first Query "AverageResponseTimeByIssue" records the average time it takes to resolve a Support Ticket based on category "NoteType" if "closed" is set to true


    The second query "AverageHoldTimeByIssue" works out the average time that tickets have been placed on hold based on category "NoteType" if "Onhold" is set to true

    what I am trying to do is subtract the on hold time from the response time but I can't get my head around how to do it,

    what I am looking for is the averageResponcetimeByIssue - AverageHoldTimeByIssue but still grouped on Notetype.

    AverageHoldtimeByissue sql

    SELECT Count(AssetNotes.AssetNotesID) AS CountOfAssetNotesID, AssetNotesType.NoteType, NZ(Avg(DateDiff("n",[HoldStartTime],[HoldEndtime])),0) AS AverageTime
    FROM AssetNotesType INNER JOIN AssetNotes ON AssetNotesType.ID = AssetNotes.NotesType
    WHERE (((AssetNotes.IssueClosed) Between [forms].[ResponceTimeDates].[startdate] And [forms].[ResponceTimeDates].[enddate]))
    GROUP BY AssetNotesType.NoteType, AssetNotes.[On Hold]
    HAVING (((AssetNotesType.NoteType) Not Like "General Note") AND ((AssetNotes.[On Hold])=True));

    AverageResponseTimeByIssue SQL

    SELECT Count(AssetNotes.AssetNotesID) AS CountOfAssetNotesID, AssetNotesType.NoteType, NZ(Avg(DateDiff("n",[issueOpenedTime],[NoteEndtime])),0) AS AverageTime
    FROM AverageHoldTimeByIssue, AssetNotesType INNER JOIN AssetNotes ON AssetNotesType.ID = AssetNotes.NotesType
    WHERE (((AssetNotes.IssueClosed) Between [forms].[ResponceTimeDates].[startdate] And [forms].[ResponceTimeDates].[enddate]))
    GROUP BY AssetNotesType.NoteType
    HAVING (((AssetNotesType.NoteType) Not Like "General Note"));

    any help would be fantastic

    Steve

  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,770
    Is NoteType the issues?

    I don't suppose both queries have all the same NoteType values?

    I do suppose you have a table of all note types?

    Join the two aggregate queries to the NoteTypes table.

    You might first want to rename the two AverageTime fields different so the new query doesn't have two fields with same name.
    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
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi June

    Thanks for the heads up, joined the queries to the table works really well

    many thanks

    steve

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

Similar Threads

  1. combining queries
    By WickidWe in forum Queries
    Replies: 1
    Last Post: 04-30-2014, 07:12 AM
  2. Help with Combining Queries
    By racefan91 in forum Queries
    Replies: 13
    Last Post: 10-07-2013, 02:42 PM
  3. Combining two queries.
    By Ray67 in forum Queries
    Replies: 1
    Last Post: 09-07-2012, 12:11 PM
  4. Combining queries..
    By Anthony88 in forum Queries
    Replies: 4
    Last Post: 05-02-2012, 02:46 PM
  5. Combining two queries
    By Adele in forum Queries
    Replies: 1
    Last Post: 07-16-2011, 12:17 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