Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    2

    Unanswered: dividing to ten problem

    Hello,

    I have a problem when running a query on smallint columns in sybase ase 11.9.2.
    When I divide by ten a smallint column, result is rounding a smallint value automatically. But I need a 2 precision after comma.
    I mean,
    Select maxsck/10 from bkl02 ; result=13
    Select maxsck from bkl02 ; result=134

    this problem may solve by programming but I need a more structural solving. I remember that, In Informix, there is a system variable DBFLOATMASK and if you define this variable for example 2 in config or profile file, query results always get 2 precision. I need similar thing in sybase.
    Is there any way?
    thanks,
    Mustafa

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Code:
    declare @x smallint, @y smallint
    select @x=9999, @y=7
    select 
      eg1=@x/7.0
    , eg2=convert(decimal(6,2),@x)/7
    , eg3=convert(decimal(6,2),@x*1.0/@y)
    , eg4=convert(decimal(6,2),round(@x*1.0/@y,2))
    
     eg1             eg2                  eg3       eg4       
     --------------- -------------------- --------- --------- 
         1428.428571   1428.4285714285714   1428.42   1428.43
    Last edited by pdreyer; 11-08-05 at 08:11.

  3. #3
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    You can also check out the STR() function.

    Michael

Posting Permissions

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