devxlogo

Record Count by Quarter

Record Count by Quarter

Question:
I have a table set up with training records by date. I want to produce a query that will count how many training sessions took place for each quarter starting with a given date through the present date.

Answer:
Have you tried something like this:

SELECT * FROM Table          WHERE session_date BETWEEN ‘1997-01-01’ AND ‘1997-03-31’;
Unless your database supports a function to determine calendar quarters,you’ll have to either hard-code the dates for which you’re searching (as inthe example above), or create a separate table that includes the beginning and ending dates for the quarter.
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist