Results 1 to 5 of 5

Thread: [RESOLVED] Divide in a SQL statement?

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Resolved [RESOLVED] Divide in a SQL statement?

    OK.. i need to do a division in an SQL statement...

    not sure how but,,,

    like

    fields: link_rating/number of links needs to return a new field called "sumrating" and be ordered by this in decending order...

    its been a long time since i did ne fing like this and i forgot how..
    so
    Wayne

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Umm... why can't you just do the division right before you create the SQL statement?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    how do u mean?...

    i need to get data from my database:

    Code:
    Select link_rating, number_of_links, (sumrating = link_rating/number_of_links) 
    from TABLE 
    Where number_of_links>0 
    ORDER BY sumrating DESC
    Wayne

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Does this not work?
    Code:
    Select link_rating, number_of_links, (link_rating/number_of_links) AS sumrating
    from TABLE 
    Where number_of_links>0 
    ORDER BY sumrating DESC
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    OK,, LOL, how simple was that

    thanks dood.
    Wayne

Posting Permissions

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



Click Here to Expand Forum to Full Width