We use datepart method to get quarter part of a date. We will do some examples on library database at below.
TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK
Example 1:
List the number of books read grouped by date quarter
1 2 3 |
Select Year(takendate) as Year, datepart(qq,takendate) as Quarter,count(*) as Count from borrows group by Year(takendate),datepart(qq,takendate) |
Result Of Query
Example 1:
List the student count gruped by date quarter
1 2 3 |
Select Year(birthdate) as Year, datepart(qq,birthdate) as Quarter,count(*) as Count from students group by Year(birthdate),datepart(qq,birthdate) |
Result Of Query