Join query in Access

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
774
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I'm a learner when it comes to access SQL and would like some help if possible
I have created a "Union All" query which is great, but the 2 queries I am joining togther are joining under each other. I beleive as I want to add the second query to the right I would need to use a join but I am unsure how to join them.

Can anyone show me how to complete this as a join or point me to somewhere online I can read and understand and attempt myself as I am unsure how to join 1 to the other on the [DL]

Code:
SELECT Table1.[DL], Sum(IIf([CS]="Pass",1,0))/Sum(IIf([Q1]="Yes",1,0)) AS [Last Week]
FROM Table1, PreviousWeek
WHERE (((Table1.[Call Marked Date]) Between [PreviousWeek].[FromDate] And [PreviousWeek].[ToDate]))
GROUP BY Table1.[DL]
HAVING (((Table1.[DL])<>"Team1"));
UNION ALL SELECT Table1.[DL], Avg(IIf([CS]="Pass",1,0))/Avg(IIf([Q1]="Yes",1,0)) AS [5 Wk Avg]
FROM Table1, FiveWeek
WHERE (((Table1.[Call Marked Date]) Between [FiveWeek].[FromDate] And [FiveWeek].[ToDate]))
GROUP BY Table1.[DL], "5 Wk Avg"
HAVING (((Table1.[DL])<>"Team1"));

thanks
Gavin
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Yes, UNION queries always increase the record (rows), but the fields (columns) wouldn't change.

Can you show us a sample of the data tables involved, and what exactly you want your expected output to look like?
 
Upvote 0

Forum statistics

Threads
1,224,800
Messages
6,181,042
Members
453,014
Latest member
Chris258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top