lionelhill
Technical User
I'm trying to work out how to sum a numerical field "A" in one table, where a ThingID field in that table has no matching ThingID field in a second table.
My first thought was to do this in two queries: one would sum "A" for the whole of the first table; the other would be a straightforward join of tables 1 and 2 and sum "A" where ThingID is common to both; the difference between the two results is what I want.
Then I found out about frustrated left join queries, where I sum data in table 1 left-joined (using ThingID) to (SELECT ThingID from table 2 AS nice-new-name) WHERE nice-new-name is null. This should sum the data only where there is no corresponding entry.
I'm interested in which is the better approach? Is it better to package all the work in a single nested query, or is it just as efficient to have two simple queries? Are nested queries safe in Access? I did find the AllenBrowne site page: This was rather terrifying:
This puts me off rather! Is it really that bad, or have things improved? I'd be grateful for any guidance.
My first thought was to do this in two queries: one would sum "A" for the whole of the first table; the other would be a straightforward join of tables 1 and 2 and sum "A" where ThingID is common to both; the difference between the two results is what I want.
Then I found out about frustrated left join queries, where I sum data in table 1 left-joined (using ThingID) to (SELECT ThingID from table 2 AS nice-new-name) WHERE nice-new-name is null. This should sum the data only where there is no corresponding entry.
I'm interested in which is the better approach? Is it better to package all the work in a single nested query, or is it just as efficient to have two simple queries? Are nested queries safe in Access? I did find the AllenBrowne site page: This was rather terrifying:
Access crashes
Subqueries can crash Access. You know the drill, "... closed down by Windows. Sorry for the inconvenience."
Unpatched bugs plague all versions of JET, so the extra complexity of a subquery can kill Access quite easily. Since we are talking about multiple diverse flaws, there is no single solution. The (rather unsatisfactory) workaround is to figure out what JET is having problems with, and take a different approach that does not trigger this particular bug.
This puts me off rather! Is it really that bad, or have things improved? I'd be grateful for any guidance.