Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2007
    Posts
    10

    Unanswered: negative sign (unary operator) not displayed for numeric data types

    I have a table with a field that has a numeric data type (15,2) and length of 9. The problem is that it won't display the actual negative sign for any values less than 0 when running a query. Any ideas? I've used Query Analyzer as well as Access.

    Thanks.
    Last edited by etaktaf; 02-20-07 at 15:20.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Huh?

    Code:
    DECLARE @x decimal(15,4)
    set @x = -12345.1234
    SELECT @x
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Feb 2007
    Posts
    10
    Maybe this will help.

    For instance, one customer in the table has values like this:

    4380.00
    4380.00
    8760.00
    4380.00
    4380.00
    23360.00
    23360.00

    but actually it should be:

    4380.00
    -4380.00
    8760.00
    -4380.00
    -4380.00
    23360.00
    -23360.00

    which nets to a total of 0. And if I change the query to a group query and perform a sum on this revenue field I will get 0 but if I do a normal select I'll get all positives. Sql server knows that some of the revenue is negative it just doesn't display the - sign infront of it.

    Btw:

    DECLARE @x decimal(15,4)
    set @x = -12345.1234
    SELECT @x

    works correctly.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    How are you viewing the data? I betcha it's a front end issue?

    Or are yu seeing this in QA.

    Read the huint sticky at the top of the board and post what it asks for
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    "select [Value] from [YourTable] where [Value] < 0" returns what?
    If it's not practically useful, then it's practically useless.

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

  6. #6
    Join Date
    Feb 2007
    Posts
    10
    I've gotten the same results using Access as the front end linking the sql server table and using Query Analzyer. I will take a look at that sticky.

    If I run the same query with the < 0 criteria I will get values returned that look positive. I even copied and pasted the values into Excel and they still show up as positive values.

    If I change the data type to float it works fine, but for some reason numeric data type won't display negative values.

  7. #7
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    are you sure you aren't running this:

    select abs(mycol) from mytable where mycol < 0



    in any case I can't repro it:
    Code:
    declare @t table (col decimal(15,2))
    insert into @t
    select -12.11 union all select 234.33 union all select -44.444
    select * from @t
    
    col
    ---------------------------------------
    -12.11
    234.33
    -44.44
    Last edited by jezemine; 02-20-07 at 20:19.

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Sorry etaktaf, but unless you can provide us with some code for replicating this problem (create table, populate table, select results...), then I don't think we can help you any further.
    If it's not practically useful, then it's practically useless.

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

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    In other words post some examplkes as the hint link states
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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