U
uk_firebrand
Hi all,
I've simplified my original post as very long winded - apologies for that;
it was a busy day at work.
I want to run a single query that has inner joins across 2 tables:2 fields
and a left join on 1 table:1 field. Due to an "ambiguous joins" issue when I
attempt to run as a single query, I have had to split this into 2 queries
i.e. inner joins in 1 query, left join in another.
I can perform this type of query in an SQL+ environment however, I'm having
issues porting the same logic to Access and I was hoping someone could assist
in creating a single, merged query.
There are 3 tables involved
a - raw data
b - criteria list for return values where 2 joined fields must be equal
(a.field=b.field)
c - a list of dates in the current year; used as left join on first query to
return all dates from c and the 1st query's results where they exist
The first query pulls back the data I need: -
SELECT a.Site, a.DATE, Sum(a.ACD_CALLS), etc...
FROM a INNER JOIN b ON (a.Site = b.Site) AND (a.Skill = b.Skill)
GROUP BY a.Site, a.DATE
ORDER BY a.DATE;
The second query references the first with a LEFT join on a table containing
all the dates in the current year and, essentially, will pull back all those
dates and any values from the first query where the dates match: -
SELECT c.Date, 1stQuery.1stField, 1stQuery.etc...
FROM c LEFT JOIN 1stQuery ON c.Date = 1stQuery.DATE
ORDER BY c.Date;
Is there any way, possibly using a subquery in the first, that I can the
merge the two queries into one?
Many thanks in advance,
I've simplified my original post as very long winded - apologies for that;
it was a busy day at work.
I want to run a single query that has inner joins across 2 tables:2 fields
and a left join on 1 table:1 field. Due to an "ambiguous joins" issue when I
attempt to run as a single query, I have had to split this into 2 queries
i.e. inner joins in 1 query, left join in another.
I can perform this type of query in an SQL+ environment however, I'm having
issues porting the same logic to Access and I was hoping someone could assist
in creating a single, merged query.
There are 3 tables involved
a - raw data
b - criteria list for return values where 2 joined fields must be equal
(a.field=b.field)
c - a list of dates in the current year; used as left join on first query to
return all dates from c and the 1st query's results where they exist
The first query pulls back the data I need: -
SELECT a.Site, a.DATE, Sum(a.ACD_CALLS), etc...
FROM a INNER JOIN b ON (a.Site = b.Site) AND (a.Skill = b.Skill)
GROUP BY a.Site, a.DATE
ORDER BY a.DATE;
The second query references the first with a LEFT join on a table containing
all the dates in the current year and, essentially, will pull back all those
dates and any values from the first query where the dates match: -
SELECT c.Date, 1stQuery.1stField, 1stQuery.etc...
FROM c LEFT JOIN 1stQuery ON c.Date = 1stQuery.DATE
ORDER BY c.Date;
Is there any way, possibly using a subquery in the first, that I can the
merge the two queries into one?
Many thanks in advance,