SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [HDI] Do Math In A Query Statement Using MYSQL?

    I want to do a SELECT on a table that has two fields, however I'd like to do a calcuation in the query for it. I lost all my good SQL bookmarks and was hoping someone knew this offhand.

    The two fields are rating and usercount. I would have to divide 'rating' by the 'usercount' to get the 'average' and then I'd like to ORDER BY the average is DESC.

    I hope I wrote this out properly...
    <///////~

    www.sohh.com

  2. #2
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SELECT [...],(rating/usercount) AS average FROM tblName ORDER BY average DESC;


Bookmarks

Posting Permissions

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