Results 1 to 6 of 6

Thread: Is there a way to obtain the average of two fields?

  1. #1
    Join Date
    Jun 2003
    Location
    NC
    Posts
    11

    Is there a way to obtain the average of two fields?

    I am putting together a database of football stats. in this database I am keeping rushing yards and average rush per yard. Is there a statement that will display the average of the Attempts field and Yards field? I noticed in the tutorials there is a way to do it with columns, but this would be averaging a two fields in a row.

    Thanks,
    David

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    please provide us what database you are using oracle,sql, access, mysql , sybase etc.

    and provide example

  3. #3
    Join Date
    Jun 2003
    Location
    NC
    Posts
    11
    I am using FrontPage, so the database is Access. Here are the fields...

    Player, Attempts, Yards, Average, Touchdowns

    I'm assuming this would be a Select statement to display the average yards per attempt.

    Select *
    From results
    Avg ???????
    Where player = '::J. Fiedler::'

    As you can tell, I'm a sure newbie. Thank you for your help

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    --For total average
    SELECT avg(attempts/yards)
    FROM Table1 where player ='J. Fiedler'

    --For individual average
    SELECT attempts/yards
    FROM Table1 where player ='J. Fiedler';

    --I dont know what this is
    SELECT sum(attempts)/sum(yards)
    FROM Table1 where player ='J. Fiedler'

  5. #5
    Join Date
    Jun 2003
    Location
    NC
    Posts
    11
    That worked out great. Thanks so much. Is there a way to shorten the values outcome? Currently it displays 4.5396543, where I'd like it to say 4.5

    Thanks so much for your help.

    David

  6. #6
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    --for 2 decimal places

    SELECT format(attempts/yards,"####.##")
    FROM Table1 where player ='J. Fiedler';


    --for 1 decimal places

    SELECT format(attempts/yards,"####.#")
    FROM Table1 where player ='J. Fiedler';

Posting Permissions

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