Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    40

    Unanswered: Weird Case Then problem

    I'm trying give letter grade to grade.

    Code:
    CASE WHEN point >= (@total_point * 0.9) THEN 'A'
    WHEN point >= (@total_point * 0.8) THEN 'B'
    WHEN point >= (@total_point * 0.7) THEN 'C'
    WHEN point >= (@total_point * 0.6) THEN 'D'
    ELSE 'F'
    END
    It's working on A, B, C, F. But not on D.

    when student gets 60 point out of 100 point It's showing F.

  2. #2
    Join Date
    Mar 2008
    Posts
    40
    Well it turns out that. 0.6 and 6/10 are different anyhow. When I use 0.6 it doesn't work but when I use 6/10 it works.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This works fine for me:
    Code:
    declare	@point int
    declare	@total_point int
    
    set		@point = 60
    set		@total_point = 100
    
    select	CASE WHEN @point >= (@total_point * 0.9) THEN 'A'
    		WHEN @point >= (@total_point * 0.8) THEN 'B'
    		WHEN @point >= (@total_point * 0.7) THEN 'C'
    		WHEN @point >= (@total_point * 0.6) THEN 'D'
    		ELSE 'F'
    		END
    Result: "D"
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Is @total_point a float?
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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