Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    24

    Question Unanswered: Display another value

    Hi, Im new at sql and i just wanted to know if its possible to do something like this

    i have a column name "Principle" and the data in this column is a dollar value. How do i write a query where when the dollar amount is <0 it displays as - and when its >0, it displays as +

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Try this
    Code:
    select CASE WHEN Principle > 0 then '+' ELSE '' END + CAST(Principle as varchar)
    Normally this stuff should be done in the presentation layer.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

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