Results 1 to 2 of 2

Thread: Percent in sql

  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Post Unanswered: Percent in sql

    I need rate to be a percent, it is returning 1 where XX=YY (e.g 100/100=1), but when the number (rate) is a fraction (90/100=.9)I am getting 0. Don't know what the problem is.

    select XX as X, YY as Y, (YY/XX) as rate from blah where blah group by XX, YY order by XX

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Try:
    PHP Code:
    SELECT 90 CAST(100 AS real
    Integer math doesn't do the decimal thing very well!

    -PatP

Posting Permissions

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