Instruction
Nice! You can also use the DATEPART() function to group data. Let's analyze the example below:
SELECT AVG(Delay) AS AvgDelay, DATEPART(year, Date) AS Year, DATEPART(quarter, Date) AS Quarter FROM Flight GROUP BY DATEPART(year, Date), DATEPART(quarter, Date);
This query calculates the average delay for all flights and groups the calculation results by quarter.
Let's practice using DATEPART() with grouping.
Exercise
Help the manager prepare a report about the routes that PerfectAir flies. Show the average delay for each hour of arrival time. Name the columns Hour and AvgDelay.



