Skip to content
Advertisement

MS Access Pass Through Query find duplicates using multiple tables

I’m trying to find all coverage_set_id with more than one benefit_id attached summary_attribute (value=2004687).

The query seems to be working fine without the GROUP BY & HAVING parts, but once I add those lines in (for the COUNT) my results are incorrect. Just trying to get duplicate coverage_set_id.

Pass-Through query via OBDC database:

My results look like this:

I’m expecting all the COUNTs to be 2.


::EDIT::

Solution:

And these were the results:

Advertisement

Answer

The coverage_set_id in both the HAVING and count part of the SELECT should be benefit_id.

Since benefit_id is also in table a you can do the following

This removes the JOIN magnification that was occurring on the FROM since those tables are not needed to pull coverage_set_id and benefit_id. The only remaining need for the other 2 tables is to filter out data based on criteria, which is in the WHERE clause.

I’m not sure what table summary_attribute lives in but it would follow a similar pattern to valid_from_date, request_status, or benefit_id.

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