Display -0

  • All,

    I want to display -0 when i run the below query

    select 0.0*-1

    karthik

  • Getting -0 as result after performing some numeric operation is not possible

    We will have to do some string concatenation to achieve this result

    Can you give a bit more details as to what you are trying to do using tables, variables, etc.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • pls find the attached documents.

    karthik

  • You will need CASE statement and some hard-coding to achieve this result

    SELECTCASE WHEN SUM(trans_amt) BETWEEN -0.99 AND 0 THEN '-0.00' ELSE CAST( SUM(trans_amt) AS VARCHAR(30)) END

    FROMacc_bal_may


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Are you producing the report?

    This one is one of the most stupid requirements I ever seen.

    Zero, as a numeric thing, cannot be negative. Some times it used for showing temperature in weather to show that it's just low enough for water to freeze.

    As soon as you add - to 0 it's stop to be numeric and starts to be a formatted string.

    I would only do it in UI (eg. reporting tool).

    If this is used for some sort of data extract, it's still will way better to show it in two separate columns. One is numeric value (0) and another one, CHAR(1), sign.

    Than you can pass whatever you like.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

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

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