Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    178

    Question Unanswered: finding the sum and average

    Hi everyone
    today's problem is this:
    i have a table that stores numeric values and corresponding dates.
    all i want to do is find the sum and average of the values within a specific month.

    there's probably a simple VB function to handle this, isn't there.
    pls help

  2. #2
    Join Date
    Jun 2002
    Location
    Houston, TX
    Posts
    116
    Why not build a group by query and with the date add a question in the criteria for the invoice like:

    [Enter date]

    HTH
    texasalynn

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select [enter month number] as themonth
         , sum(thenumber)       as sumnumbers
         , avg(thenumber)       as avgnumbers
      from thetable
     where month(datefield)
         = [enter month number]
    GROUP BY is not required if the aggregates are taken over the entire result set, as filtered by the WHERE clause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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