Replacing 0 column

  • Hi,

    Query:

    Select

        Colum1,

        Column2,

        Column1/Column2

    From

        SampleTable

    Problem:

    There may be zero in column1 or column2 or both. Now i want the third column in result set (Column1/Column2) to be zero if either or both columns have ZERO. How can i achive this in a single query.

    Thanks,

    Hatim Ali.

  • select Colum1,Column2,

    case

    when Colum1 = 0 then 0

    when Column2 = 0 then 0

    else Colum1/Column2

    end as Colum3

    from SampleTable

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

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