Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8702107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:34:07+00:00 2026-06-13T02:34:07+00:00

The table structure described is just for guidance. The column names are different compared

  • 0

The table structure described is just for guidance. The column names are different compared to that of the DB.

I have a rather an unusual DB. I have agent table (Agents) with following structure.

A_ID(PK)|    AgentName    |    Team
------------------------------------
1       |    Abi          |    New
2       |    Carl         |    New
3       |    James        |    New

I have two other tables that has several fields but the ones in question have fields like..

Table: Transactions

ID(PK)  |    manyColumns  |    Agent_ID    |    OUTCOME
--------------------------------------------------------
96      |    ...          |    1           |    9          
98      |    ....         |    2           |    8       
99      |    .....        |    3           |    1       

Table: RAWDATA

ID(PK)  |    manyColumns  |    Agent_ID    |    BANK_OUTCOME
-------------------------------------------------------------
1234    |    ...          |    1           |    3
1114    |    ....         |    2           |    333
1745    |    .....        |    3           |    123

I have a log table with the details of the staff working hours..

Table: AGENT_ATTENDANCE

ATT_ID  |    Hours Worked |    Agent_ID_FK 
-------------------------------------------
96      |    7.5          |    1            
98      |    7.5          |    2             
99      |    7.5          |    3           

I also have a details of staff pay, hours contracted.

Table: AGENT_DETAILS

DT_ID   |    Hours WK      |    Pay    |    Agent_ID_FK 
-------------------------------------------------------
96      |    37.5          |    15600  |    1            
98      |    37.5          |    15600  |    2             
99      |    37.5          |    15600  |    3           

I have created separate queries but I want to display as one.. As the calculation depend on each other.. I am not sure how to do it.. The following are separate Queries.. How can I JOIN them as one??

Query – 1:

PARAMETERS [EnterStartDate:] DateTime, [EnterEndDate:] DateTime;

SELECT Agents.[Agent Name], 
Sum(IIf((([TRANSACTIONS].[BankOutcome]=3) Or ([TRANSACTIONS].[BankOutcome]=333)),1,0)) AS PositiveOutcome, 
Count(RAWDATA.Outcome) AS TotalRecordsUsed

FROM (RAWDATA LEFT JOIN Agents ON RAWDATA.[AGENT_ID] = Agents.A_ID) LEFT JOIN
TRANSACTIONS ON RAWDATA.ID = TRANSACTIONS.RAW_ID 

WHERE (((RAWDATA.DialedDate) Between [EnterStartDate:] And [EnterEndDate:]))

GROUP BY Agents.[Agent Name], RAWDATA.AGENT_ID

HAVING (((RAWDATA.AGENT_ID) Is Not Null));

Query – 2:

PARAMETERS [EnterStartDate:] DateTime, [EnterEndDate:] DateTime;

SELECT Agents.[Agent Name], AGENT_DETAILS.WK_TARGET_HOURS,
Sum(AGENT_ATTENDENCE.HoursWorked_Day) AS [Actual Hours Worked], 
[WK_TARGET_HOURS]-[Actual Hours Worked] AS [Hours Lost], AGENT_DETAILS.SALARY, 
Round([SALARY]/252/([WK_TARGET_HOURS]/5),2) AS [Hourly Rate], [Hourly Rate]*[Actual Hours Worked] AS [Staff Cost]

FROM (Agents INNER JOIN AGENT_DETAILS ON Agents.A_ID = AGENT_DETAILS.AGENT_ID_fk)
INNER JOIN AGENT_ATTENDENCE ON Agents.A_ID = AGENT_ATTENDENCE.AGENT_ID_fk

WHERE (((AGENT_ATTENDENCE.WorK_Date) Between [EnterStartDate:] And [EnterEndDate:]))

GROUP BY Agents.[Agent Name], AGENT_DETAILS.WK_TARGET_HOURS, AGENT_DETAILS.SALARY, 
Agents.Active, Agents.Team

HAVING (((Agents.Active)=True) AND ((Agents.Team)<>"Manager" And (Agents.Team)<>"Cust. Ser."));

Could attach the file if I could but I do not know how to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:34:09+00:00Added an answer on June 13, 2026 at 2:34 am

    I did not get into your code, but roughly you have 3 choices:

    • If both queries have the same fields (not your case apparently) you can use a UNION query to have the data of both queries in 1 dataset.
    • Otherwise, you can use query1 as the source of query2
    • Finally you can build query1 and query2, then use a third query to JOIN the first 2
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a polygon structure in an sql2005 db as described below. CREATE TABLE
Currently in my application I have a single table that is giving me a
I have a table with the following structure: WorkerPersons ------------------------------- ID (PK) PersonID (Indicates
I've got the following JSON structure that defines a table and it's data. var
A short description: I have a table with data that is updated over a
Suppose we have 4 tables as described below: Table 1: Element element_id [integer] (PK)
First, I'll describe my table structure. I have table, with 2 columns (ID and
Current situation: I have a database with following structure: Product Category (contains column product_id)
I have a table that contains three pieces of patient information. Diagnosis_ID Patient_ID Diagnosis_Code
I used a query a few weeks ago in MySQL that described a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.