Results 1 to 3 of 3
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    Help Creating a Query to Extract 2 Results from same table

    Greetings ~



    I am trying to create a query that will provide two results from the same table

    This essectially takes the previous query I was working on here and adds another field and provides another result from the same data

    Below is the query which at the moment produces a Dupliate Output Alias Error on the HandleTime field
    Code:
    SELECT TblACD.CallDate, TblACD.AgentID, TblACD.EmpName, TblACD.TeamName, Sum(TblACD.HandleTime) AS HandleTime, Sum(TblACD.CallsHandled) AS CallsHandled, Format((HandleTime/CallsHandled),"0") AS AvgHandleTime, 
    Sum(TblACD_1.HandleTime) AS HandleTime, Sum(TblACD_1.CallsHandled) AS CallsHandled, Format(([TblACD_1].[HandleTime]/[TblACD_1].[CallsHandled]),"0") AS AvgHandleTime2
    FROM TblACD, TblACD AS TblACD_1
    WHERE (((TblACD.CallDate)=#10/14/2019#) AND ((TblACD.AgentID)="HF171627") AND ((TblACD_1.CallDate)=#10/14/2019#-3) AND ((TblACD_1.AgentID)="HF171627"))
    GROUP BY TblACD.CallDate, TblACD.AgentID, TblACD.EmpName, TblACD.TeamName, TblACD.Location, TblACD_1.CallDate, TblACD_1.AgentID;
    I've tried to alias the HandleTime Field but then, of course I get a plethora of other errors: Circular/Not part of Aggregate Function/ et.al

    I'm sure (ok I hope) this one will be easier than the last one

    Sorry 'bout that btw - the solution was right in front of my face and I just couldn't see it.

    Thanks as always for any help

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    make Q1 to get your data,
    make Q2 that uses Q1 to get the 2nd datum.
    combine them in a union query:

    select * from Q1
    union select * from Q2

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    RanMan - Thank You!!!

    This Worked!
    Code:
    (SELECT TblACD.CallDate, TblACD.AgentID, TblACD.EmpName, TblACD.TeamName, TblACD.Location, Sum(TblACD.HandleTime) AS HandleTime, Sum(TblACD.CallsHandled) AS CallsHandled, Format(([HandleTime]/[CallsHandled]),"0") AS AHT
    FROM TblACD
    WHERE (((TblACD.CallDate)=#10/14/2019#) AND ((TblACD.AgentID)="HF171627"))
    GROUP BY TblACD.CallDate, TblACD.AgentID, TblACD.EmpName, TblACD.TeamName, TblACD.Location)
    
    
    UNION
    
    
    (SELECT TblACD.CallDate, TblACD.AgentID, TblACD.TeamName, TblACD.TeamName, TblACD.Location, Sum(TblACD.HandleTime) AS HandleTime, Sum(TblACD.CallsHandled) AS CallsHandled, Format(([HandleTime]/[CallsHandled]),"0") AS AHT
    FROM TblACD
    WHERE (((TblACD.CallDate)=#10/11/2019#) AND ((TblACD.AgentID)="HF171627"))
    GROUP BY TblACD.CallDate, TblACD.AgentID, TblACD.EmpName, TblACD.TeamName, TblACD.Location)
    Thank You again, Ranman...

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

Similar Threads

  1. Query to extract selected fields from table
    By Traceyann1964 in forum Queries
    Replies: 2
    Last Post: 08-30-2016, 07:12 AM
  2. Replies: 5
    Last Post: 03-24-2014, 07:04 AM
  3. Replies: 5
    Last Post: 05-21-2013, 02:21 PM
  4. Replies: 3
    Last Post: 05-13-2010, 08:18 PM
  5. Replies: 1
    Last Post: 02-02-2010, 07:19 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