Hi @pilotguy251
Try this:
Declare @temp table(ID INT identity(1,1), T_Date Datetime,Number int)
insert into @temp values
('2021-01-01',16316),('2021-02-01',14860),
('2022-01-01',16051),('2022-02-01',15051),
('2023-01-01',15696),('2023-02-01',14797)
DECLARE @Month INT
SET @Month=1
SELECT AVG(Number) AS Jan_Avg
FROM @temp
WHERE MONTH(T_Date) = @Month
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.