1 point for every 3 multiples in a row

  • Hi,

    I need to assing 1 point for every 3 multiples in a row for expample

    col1 6 then col2 should be 2

    if col1 5 then col2 should be 1

    Thanks

  • Simple Integer math should take care of it...

    SELECT Col1/3

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • DECLARE @test INT, @divisor INT

    SET @divisor = 3

    SET @test = 6

    SELECT @test / @divisor AS '6'

    SET @test = 5

    SELECT @test / @divisor AS '5'

    Edit: I guess Jeff beat me to it. Thanks!

    -- Cory

  • Cory E. (1/10/2011)


    Edit: I guess Jeff beat me to it. Thanks!

    Apparently, only by a couple of seconds! Great minds think alike. 🙂

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply