sltan32
asked on
Access SQL query for Crosstab query not working
Hi, I'm trying to create a crosstab query in Access 2007 and I'm encountering the following error message after setting up the join property.
The error message is "The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs that first join and then include that query in your SQL statement."
I'm also enclosing the SQL query for reference:
TRANSFORM Sum(MPlanShipment.NoOfPcs) AS SumOfNoOfPcs
SELECT MPlanShipment.ShipmentCode , tblForwarder.ForwarderName
FROM tblForwarder INNER JOIN (Tbl_Next7days LEFT JOIN MPlanShipment ON Tbl_Next7days.Cur_Date = MPlanShipment.ContTrucking date) ON tblForwarder.ForwarderID = MPlanShipment.Forwarder
GROUP BY MPlanShipment.ShipmentCode , tblForwarder.ForwarderName
PIVOT Tbl_Next7days.Cur_Date_Wkd ayName;
Appreciate if you can advise how to amend the SQL query in order run the report. Thanks you very much.
Access-SQL-Setup.JPG
SQL-Error-message.JPG
The error message is "The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs that first join and then include that query in your SQL statement."
I'm also enclosing the SQL query for reference:
TRANSFORM Sum(MPlanShipment.NoOfPcs)
SELECT MPlanShipment.ShipmentCode
FROM tblForwarder INNER JOIN (Tbl_Next7days LEFT JOIN MPlanShipment ON Tbl_Next7days.Cur_Date = MPlanShipment.ContTrucking
GROUP BY MPlanShipment.ShipmentCode
PIVOT Tbl_Next7days.Cur_Date_Wkd
Appreciate if you can advise how to amend the SQL query in order run the report. Thanks you very much.
Access-SQL-Setup.JPG
SQL-Error-message.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It was mean to replace:
INNER JOIN (Tbl_Next7days LEFT JOIN
Or just double-click the inner join in the designer and change the join to a left join.
If it still doesn't work (I don't have your tables), move the inner-joined tables to a subquery.
/gustav
INNER JOIN (Tbl_Next7days LEFT JOIN
Or just double-click the inner join in the designer and change the join to a left join.
If it still doesn't work (I don't have your tables), move the inner-joined tables to a subquery.
/gustav
ASKER
problem solved as it is caused by another join in the statement that is not configured properly
ASKER
Found out the reason that causes the SQL not to work as it is caused by another join not properly configured.
LEFT JOIN (Tbl_Next7days LEFT JOIN
/gustav