Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2014
    Posts
    35

    Unanswered: Calculating percentages

    I have a table - evaluation - with, amongst others, fields ‘evalid’ and ‘clear’ . Clear can only be Yes or No.
    I want to be able to calculate the percentage (to 1 decimal place) ‘Yes’ answers but am not sure the best way to do this.
    Any guidance please?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    SELECT Count(*) As total
         , Sum(CASE WHEN clear = 'Yes' THEN 1 ELSE 0 END) As yes
         , Sum(CASE WHEN clear = 'No'  THEN 1 ELSE 0 END) As no
    FROM   evaluation
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2014
    Posts
    35
    Doesn't this just give the totals rather than the %ages.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yes, divide them to get percentages.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'm sorry the answer wasn't on a silver platter
    George
    Home | Blog

Posting Permissions

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