i'm confused. i'm doing a simple join with totals. i'm grouping on some fields, counting other fields. i would expect that all the COUNT fields would return identical counts, because they're all counting the same table. but the counts are different. why?
The attached image shows the query in design view. In Units table, each UnitID+TJC combo appears only once. In AggComplianceData, each combo can appear multiple times.
Here's the sql:
PARAMETERS FromDate DateTime, ToDate DateTime;
SELECT AggComplianceData.TJC, Units.UnitName, AggComplianceData.UnitID, AggComplianceData.AHRI, Count(AggComplianceData.Finding) AS CountOfFinding, Count(AggComplianceData.Action) AS CountOfAction, Count(AggComplianceData.TJC) AS CountOfTJC
FROM AggComplianceData INNER JOIN Units ON (Units.TJC = AggComplianceData.TJC) AND (AggComplianceData.UnitID = Units.UnitID)
WHERE (((AggComplianceData.Period) Between [FromDate] And [ToDate]))
GROUP BY AggComplianceData.TJC, Units.UnitName, AggComplianceData.UnitID, AggComplianceData.AHRI;
Here's an excerpt of the results:
TJC UnitName UnitID IntAHRI CountOfFinding CountOfAction CountOfTJC 2720 Acute Rehab 3c-ar 16 3 2 3 2720 Acute Rehab 3c-ar 18 2 2 2 2720 Acute Rehab 3c-ar 58 1 0 1 2720 Acute Rehab 3c-ar 66 1 1 1 2720 Acute Rehab 3c-ar 69 2 2 2 2720 Acute Rehab 3c-ar 71 5 4 5 2720 Acute Rehab 3c-ar 72 1 1 1 2720 Acute Rehab 3c-ar 101 0 2 2 2720 Acute Rehab 3c-ar 200 2 2 2 2720 Bridges INPATIENT 4e-brges 1 1 1 1
Here's the raw AggComplianceData for TJC 2720, UnitID 3c-ar, intAHRI 16:
SurveyID TJC UnitID Period Finding AHRI RootCause Action DateDue IntAHRI 2720.3c-ar.213 2720 3c-ar 2/1/2013 Missing times on some of progress noted. 16
16 2720.3c-ar.613 2720 3c-ar 6/1/2013 Admission progress not not signed; corrected on spot. 16 P&P not followed Corrected at tiome of survey 6/1/2013 16 2720.3c-ar.713 2720 3c-ar 7/1/2013 Dr. Abadee: Physician orders (multiple) were illegible. 16
16
note, i also posted this question here-
http://www.mrexcel.com/forum/microso...different.html