Record Count by Quarter

Record Count by Quarter

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.

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.


Share the Post: