SQL Join Query

gmazza76

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

I have around 5 tables I want to create one overall query from, but I am coming up against an issue when creating my first join
I use the code below to pull agent names etc... from a source table which is ok, but I will need to add the 2nd query below

I will need to do around 5 more queries like "Query2" but no matter what I try I cannot work out which join is best as I want the data to be to the right of the "initial Query" and how I would work out the multiple WHERE clauses and table naming. I have had a look and I have tried several ways of doing this but I usually get an error either with the JOIN or syntax issue


Code:
Initial Query
select [AgentID], [Name], [SDate], [Lead] AS [Department Lead], [Team Leader]
from Table1
Where CISCOID is not null and [CX_Lead] = 'Nxxxme' and [Title] = 'Standard'

code works on The following to calculate a field on its own

Code:
Query2

SELECT [Cdate] as [Call Date], count([AgentID]) as [IB]
FROM Table2
WHERE (((Table2.[Lead])='Name') AND ((Table2.[Flag])='Handled'))
GROUP BY Table2.[CDate], Table2.[agent], Table2.[Manager];

thanks in advance
Gavin
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I have currently tried to do a left join as follows

Code:
SELECT [AgentID], [Name], [SDate], [Lead] AS [Department Lead], [Team Leader], count(c.[Agent Peripheral Number])
FROM Table1
LEFT JOIN Table2 c ON AgentID = c.[AGENTID2]
WHERE (c.[Lead])='Name') AND ((c.[Flag])='Handled')

But I get an error JOIN expression not supported

thanks
 
Upvote 0
TBH, I do most of my sql starting from the QBE design window, then modify that, if that does not aupport a particular aspect of what I am trying to do.

Thinking about it, it is just criteria, whether any exists is a different matter. :)
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

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