No Decimal in Reults

  • The results of the below Query are 85.074626865671600 I want to make this only 85%, but not sure how to do this.

    select (SELECT Count(CallLog.ClosedBy)*1.0 From [Support].[dbo].[CallLog] WHERE ClosedDate Between '2009-01-07' and '2009-01-08')

    /

    (SELECT Count(CallLog.RecvdBy)*1.0 From [Support].[dbo].[CallLog] WHERE RecvdDate Between '2009-01-07' and '2009-01-09') *100 as pct

  • how about using 'round' ?



    Clear Sky SQL
    My Blog[/url]

  • ... or CONVERT(INT, 85.074626865671600)

  • I am not sure how to do either of those I am about a week into learning / using SQL, sorry I am a newbie

  • You can enclose your current result with ROUND/CONVERT. Follow Dave's links to see how the functions work.

    Greets

    Flo

  • This might assist:

    -- Create a test table variable

    DECLARE @CallLog

    TABLE

    (

    ClosedBy VARCHAR(30) NULL,

    RecvdBy VARCHAR(30) NULL

    );

    -- Some sample data

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES ('Bob', 'Alan');

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES (NULL, 'Charlie');

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES ('Gene', 'Sally');

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES ('Susan', 'Bob');

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES (NULL, 'Gene');

    INSERT @CallLog (ClosedBy, RecvdBy) VALUES ('John', 'Gene');

    -- The query

    SELECT pct = FLOOR(ROUND(COUNT(ClosedBy) * 100.0 / COUNT(RecvdBy), 0))

    FROM @CallLog;

  • Round(Number to be rouned, number of digit after the '.')

  • Try out this sorry if I'm wrong,

    select ceiling(85.074626865671600),floor(85.074626865671600),round(85.074626865671600,1)

  • i think round(number,0) or floor(number) do that

  • Omar halwagy (11/9/2009)


    i think round(number,0) or floor(number) do that

    i think round(number,0) -->round (85.074626865671600,0) will display like this '85.000000000000000'

    Thanks,

    Chandru

  • that true wasnt he want to get 85 ?

  • How would I put it in the this Query?

    select (SELECT Count(CallLog.ClosedBy)*1.0 From [Support].[dbo].[CallLog] WHERE ClosedDate Between '2005-01-07' and '2010-01-08')

    /

    (SELECT Count(CallLog.RecvdBy)*1.0 From [Support].[dbo].[CallLog] WHERE RecvdDate Between '2005-01-07' and '2010-01-09') *100 as pct

    Everything I try gives me a syntax error

  • It would help if you provided the actual error message you are getting.

  • jason.gerding (11/9/2009)


    How would I put it in the this Query?

    select (SELECT Count(CallLog.ClosedBy)*1.0 From [Support].[dbo].[CallLog] WHERE ClosedDate Between '2005-01-07' and '2010-01-08')/(SELECT Count(CallLog.RecvdBy)*1.0 From [Support].[dbo].[CallLog] WHERE RecvdDate Between '2005-01-07' and '2010-01-09') *100 as pct

    Everything I try gives me a syntax error

    Have you tried running the code I posted before?

    I went to great trouble to provide sample data, and give you a finished optimized query.

    Did you read it or try it or think about it?

    It's difficult to stay positive some days.

Viewing 15 posts - 1 through 14 (of 14 total)

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