Query criteria by month (1 Viewer)

tihmir

Registered User.
Local time
Today, 05:59
Joined
May 1, 2018
Messages
257
Hi all. I am trying to solve the following problem. I have 2 tables - tblObjects and tblInspections. When I build query with that 2 tables
I want to create a criterion that allows me to filter for each type of object how many times in the quarter there are inspections - for each quarter (from 01.01. to 31.03.; from 01.04. to 30.06.; from 01.07. to 30.09. from 01.10. to 31.12.). Then to use the form fmFilter and when I set a year for example 2022 it shows me the corresponding frequency of inspections (1, 2, 3, n .... times a year)for each object
 

Attachments

  • DB (1).zip
    82 KB · Views: 60

XPS35

Active member
Local time
Today, 14:59
Joined
Jul 19, 2022
Messages
159
I think your query should look like:
Code:
SELECT ObjectType, DatePart("yyyy",dateInspection) & "/" & DatePart("q",dateInspection) AS Quarter, inspectionType, Count(object_id) AS NoOfInspections
FROM tblObjects INNER JOIN tblInspections ON tblObjects.ID = tblInspections.object_id
GROUP BY ObjectType, DatePart("yyyy",[dateInspection]) & "/" & DatePart("q",[dateInspection]), inspectionType;
 

tihmir

Registered User.
Local time
Today, 05:59
Joined
May 1, 2018
Messages
257
I think your query should look like:
Code:
SELECT ObjectType, DatePart("yyyy",dateInspection) & "/" & DatePart("q",dateInspection) AS Quarter, inspectionType, Count(object_id) AS NoOfInspections
FROM tblObjects INNER JOIN tblInspections ON tblObjects.ID = tblInspections.object_id
GROUP BY ObjectType, DatePart("yyyy",[dateInspection]) & "/" & DatePart("q",[dateInspection]), inspectionType;
Thanks for your time and reply. I will try now
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:59
Joined
May 7, 2009
Messages
19,245
see crosstab query qryCrosstab.
 

Attachments

  • DB (1).zip
    76 KB · Views: 70

Users who are viewing this thread

Top Bottom