dkmoreland
Registered User.
- Local time
- , 19:33
- Joined
- Dec 6, 2017
- Messages
- 129
I have a query which returns all the jobs that have an NCR associated with them:
This returns 9 records, which is correct. However, 3 of them have the same jobnum, which is also correct. I need to only count each job number once so I can display it on a form and am using the below this statement in a different query to do the count. The problem is that the result is totaling 6 instead of 7, which is what I think it should be. If I count manually and count only once the one with multiple occurrences, I come up with 7.
Does anybody see a hole in my logic or is my second query statement incorrect?
Before you mention it - I am aware that field names should not have special characters in them. This is an inherited problem that is taking forever to fix.
Thanks in advance for any and all input on this.
Code:
SELECT DISTINCT [Non Conformance].[NCR#], [Production raw data].jobnum, [Production raw data].start_date, [Production raw data].end_date, [Production raw data].jobname
FROM [Non Conformance] INNER JOIN [Production raw data] ON [Non Conformance].[Job #] = [Production raw data].jobnum
WHERE ((([Production raw data].start_date) Between [Forms]![KPI data form]![TxtStartDate] And [Forms]![KPI data form]![TxtEndDate]));
This returns 9 records, which is correct. However, 3 of them have the same jobnum, which is also correct. I need to only count each job number once so I can display it on a form and am using the below this statement in a different query to do the count. The problem is that the result is totaling 6 instead of 7, which is what I think it should be. If I count manually and count only once the one with multiple occurrences, I come up with 7.
Code:
SELECT Count(*) AS ncrjobs
FROM (SELECT DISTINCT jobnum FROM [jobs_with_NCRs]) AS [Jobs_with_NCRs] ;
Does anybody see a hole in my logic or is my second query statement incorrect?
Before you mention it - I am aware that field names should not have special characters in them. This is an inherited problem that is taking forever to fix.

Thanks in advance for any and all input on this.