Skip to content
Advertisement

Optimizing Access Query with Multiple sub-queries

I have a table of data that contains baseline project information, called ADMIN_WORK. I have a separate table that contains various attributes related to each project listed in ADMIN_WORK called WR_ATTRIBUTE. The structure of WR_ATTRIBUTE is such that each project has about 300 attributes (300 rows in the table) each with a unique name associated with the project number. I need to pull approximately 15 of these attributes into a final table.

I built a query with a number of sub-queries, but it takes multiple hours to run. The code below represents pulling a single attribute (called Circuit) from WR_ATTRIBUTE for all projects.

My final query has about 14 more of these subqueries similarly implemented, each with a different WR_ATTRIBUTE_CODE.

My final table is generated accurately, but it is extremely slow. I am wondering if there is a better way of structuring my query.

Advertisement

Answer

You probably just want conditional aggregation:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement