Question : SQL Average from Query

Hi to all,

How can I get the Averege Transactions per month for the query below?

Thanks to all.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
SELECT  DATEPART(Month, [Transaction].Time) As Month,
DATEPART(DAY, [Transaction].Time) AS Day,   
COUNT(*) AS TotalTran ,   
SUM([Transaction].Total) AS Total  
FROM Register   
INNER JOIN Batch ON Register.ID = Batch.RegisterID   
INNER JOIN [Transaction] ON Batch.BatchNumber = [Transaction].BatchNumber   
WHERE [Transaction].Time BETWEEN '08/01/2005' AND '12/31/2009'
GROUP BY DATEPART(Month, [Transaction].Time),   
DATEPART(DAY, [Transaction].Time)

Answer : SQL Average from Query

And because you have multiple years, try like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
SELECT  DATEPART(Month, [Transaction].Time) As Month, 
YEAR([Transaction].Time) as [Year],
COUNT(*) AS TotalTran ,    
SUM([Transaction].Total) AS Total, 
AVG([Transaction].Total) as avgTotal 
FROM Register    
INNER JOIN Batch ON Register.ID = Batch.RegisterID    
INNER JOIN [Transaction] ON Batch.BatchNumber = [Transaction].BatchNumber    
WHERE [Transaction].Time BETWEEN '08/01/2005' AND '12/31/2009' 
GROUP BY DATEPART(Month, [Transaction].Time), YEAR([Transaction].Time)
Random Solutions  
 
programming4us programming4us