Featured post
MS Access SQL: Troubles combining UNION ALL with a LEFT JOIN -
i have created query in ms access simulate full outer join , combine results looks following:
select nz(estimates.employee_id, actuals.employee_id) employee_id , nz(estimates.a_date, actuals.a_date) a_date , estimates.estimated_hours , actuals.actual_hours (select * estimates left join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date union select * estimates right join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date estimates.employee_id null or estimates.a_date null) qfulljoinestimatesactuals
i have saved query object (let's call qestimatesandactuals
). objective left join qestimatesandactuals table. following:
select * qjoinedtable left join (select * labor_rates) rates on qjoinedtable.employee_id = rates.employee_id , qjoinedtable.a_date between rates.begin_date , rates.end_date
ms access accepts syntax , runs query, omits results within result set. wondering if date format somehow lost, placed format around begin_date , end_date force them interpreted short dates. oddly, produced different result set, still omitted result shouldn't have.
i wondering if queries performed in such way can't left join result set of union all. have thoughts/ideas on this? there better way of accomplishing end goal?
i try breaking each part of query own access query object, e.g.
select * estimates left join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date
would qryone
select * estimates right join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date estimates.employee_id null or estimates.a_date null
would qrytwo
select * qryone union select * qrytwo
would qryfulljoinestimatesactuals, , finally
select nz(estimates.employee_id, actuals.employee_id) employee_id , nz(estimates.a_date, actuals.a_date) a_date , estimates.estimated_hours , actuals.actual_hours qryfulljoinestimatesactuals
i've found constructs don't work in complex access sql statements work if broken down individual query objects , reassembled step-by-step. additionally, can test each part of query individually. find workaround if 1 proves necessary.
- Get link
- X
- Other Apps
Comments
Post a Comment