Results 1 to 3 of 3

Thread: Problem in a query

  1. #1

    Thread Starter
    Hyperactive Member gooden's Avatar
    Join Date
    Dec 2006
    Location
    Portugal
    Posts
    274

    Problem in a query

    Well i have on a server instaled a sqlexpress and in a query i have a little problem with the decimals.

    I have the query:

    select (20/100+1) AS number from documents

    the value that return is 1 when it should return 1,2

    o.0

    somebody know what this is?


    The Future Is Always The Way To Live The Life

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Problem in a query

    Both number are integer values go you get an integer result. Add a number to make it a decimal value
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Problem in a query

    From the SQL Server documentation for the / (Divide) operator:
    Result Types
    Returns the data type of the argument with the higher precedence. For more information, see Data Type Precedence (Transact-SQL).

    If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated.
    Documentation is worth a read now and again.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width