Getting the SUM of length

  • I have managed to calculate the sum of the length but the it displays this..

    2.49084932

    What must I do to display the result only in 2 decimal points?

    example : 2.49

    Thanks

    eat when you can and not when you cannot.


    eat when you can and not when you cannot.

  • Try this:

    select convert(decimal(10,2),2.49084932)

    Jeremy

  • hey there,

    I tried your method, but it doesn't seem to work.

    SUM(d.length)/1000 AS LENGTH

    should I be doing this?

    convert(decimal(10,2)sum(d.length)/1000)) as length?

    while I am at it, have to i have multiple 'between's'??

    example : i want to display id's between this numbers

    15-20, 30-40 and 50-60

    only id's within this range. How do I include this in my sql query?

    i am very new at this

    eat when you can and not when you cannot.


    eat when you can and not when you cannot.

  • Hi,

    with a small correction in the typo

    convert(decimal(10,2), sum(d.length)/1000)) as length

    that should work

    to display the range try a WHERE field BETWEEN <low> AND <high>

    or WHERE field > <low> AND field < <high>

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • You should use CAST instead of CONVERT this is where MS is going with things.

    CAST((sum(d.length)/1000) AS decimal(10,2))

  • hey thanks Antares686

    that worked well. thanks so much guys

    eat when you can and not when you cannot.


    eat when you can and not when you cannot.

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

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