Am developing a stock management. I'll be registering all the products that am buying randomly with their price. I want a query that will select all records of a particular product from the table and give me the average price of that product.
- Tbl_Purchases being the name of the table,
- ProductId being the name of the column in Tbl_Purchases that identifies a product,
- Price being the name of the column in Tbl_Purchases that contains the price.
To know the average price of the product with ProductId=1, use:
SELECT Avg(Tbl_Purchases.Price) AS AveragePrice