SQL calculation averages

SQL calculation averages

Hello! 

I am currently working with a table of data that is collected by date. I have three main columns of data that I'm working with.

1. Quantity
2. Type of product
3. Location

I have another table that I'm joining to create a new one that adds a column to translate each date into one of two categories (date type). 

1. Promo
2. Nonpromo

What I'm interested in accomplishing is an average quantity by product by month by date type. But the average calculation needs to be done by summing up the quantity of each product in each given month (one for each date type) divided by the number days of each date type respectively.  I know how to get the query to sum up the quantity and group by product by day type, but I'm struggling with getting the averages and comparing ave quantity by date type.  

I thought I had a solution and the calculations looked right, but it wouldn't allow me to save the query because I exceeded the allowed amount if queries over queries. Then I had another solution that I thought would work but it timed out trying to run. 

I should note that an issue is that there are multiple products in the database, therefore on one single date there could be 10 products sold that day. so averaging quantity is difficult because the query is averaging based on number of total rows.

Can you help me? 

Thanks

Jamie