Results 1 to 2 of 2

Thread: Average query

  1. #1
    Join Date
    May 2013
    Posts
    3

    Lightbulb Unanswered: Average query

    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.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    With:
    - 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:
    Code:
    SELECT Avg(Tbl_Purchases.Price) AS AveragePrice
    FROM Tbl_Purchases
    WHERE Tbl_Purchases.ProductId=1;
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •