R
Ray S.
I have a SQL query that I need to translate so that MS Access can understand
and run it. The query works fine. It gives the desired results, but I can't
use it in MS Access at all. I keep getting a bunch of errors as I try to
"translate" it into something that Access will understand. Here's the query.
I'd appreciate if anyone can tell me why Access won't run it and what has to
be changed so that it will. For example, I know that || ' ' || is not
recognizable in Access - it must be changed to &""&. Also, I know that
something like cc.description cc_desc must be "translated" into
cc.description AS cc_desc. Can anyone help me with this? It's pretty complex,
and I really can't give you the tables (they're all named here).
I'm especially having trouble with the sub-joins:
SELECT cc.cc_nbr,
cc.description cc_desc,
fa.description functional_area,
m.description serv_type_2008,
e1.first_name || ' ' || e1.last_name cc_mgr,
e2.first_name || ' ' || e2.last_name cc_mgr_mgr
FROM ibc_cost_center cc
INNER JOIN ibc_cc_manager cm ON cc.id = cm.cost_center_id
INNER JOIN ibc_employee e1 ON e1.id = cm.employee_id
LEFT JOIN ibc_job_position jp1 ON jp1.id = e1.job_position_id
LEFT JOIN ibc_job_position jp2 ON jp2.id = jp1.manager_job_position_id
LEFT JOIN ibc_employee e2 ON jp2.id = e2.job_position_id
LEFT JOIN ibc_functional_area fa ON fa.id = cc.functional_area_id
LEFT JOIN
(SELECT st.description, cc2.id cost_center_id
FROM ibc_service_type_cc stcc
inner join ibc_cost_center cc2 ON cc2.id = stcc.cost_center_id
inner join ibc_service_type st ON st.id= stcc.service_type_id
inner join ibc_fiscal_year fy ON fy.id = st.fiscal_year_id
WHERE fy.year = 2008 ) m ON cc.id = m.cost_center_id
ORDER BY cc.cc_nbr
and run it. The query works fine. It gives the desired results, but I can't
use it in MS Access at all. I keep getting a bunch of errors as I try to
"translate" it into something that Access will understand. Here's the query.
I'd appreciate if anyone can tell me why Access won't run it and what has to
be changed so that it will. For example, I know that || ' ' || is not
recognizable in Access - it must be changed to &""&. Also, I know that
something like cc.description cc_desc must be "translated" into
cc.description AS cc_desc. Can anyone help me with this? It's pretty complex,
and I really can't give you the tables (they're all named here).
I'm especially having trouble with the sub-joins:
SELECT cc.cc_nbr,
cc.description cc_desc,
fa.description functional_area,
m.description serv_type_2008,
e1.first_name || ' ' || e1.last_name cc_mgr,
e2.first_name || ' ' || e2.last_name cc_mgr_mgr
FROM ibc_cost_center cc
INNER JOIN ibc_cc_manager cm ON cc.id = cm.cost_center_id
INNER JOIN ibc_employee e1 ON e1.id = cm.employee_id
LEFT JOIN ibc_job_position jp1 ON jp1.id = e1.job_position_id
LEFT JOIN ibc_job_position jp2 ON jp2.id = jp1.manager_job_position_id
LEFT JOIN ibc_employee e2 ON jp2.id = e2.job_position_id
LEFT JOIN ibc_functional_area fa ON fa.id = cc.functional_area_id
LEFT JOIN
(SELECT st.description, cc2.id cost_center_id
FROM ibc_service_type_cc stcc
inner join ibc_cost_center cc2 ON cc2.id = stcc.cost_center_id
inner join ibc_service_type st ON st.id= stcc.service_type_id
inner join ibc_fiscal_year fy ON fy.id = st.fiscal_year_id
WHERE fy.year = 2008 ) m ON cc.id = m.cost_center_id
ORDER BY cc.cc_nbr