brgdotnet
asked on
rounding, and truncating a number
I have a SQL Server query that is returning my values with many values beyond the decimal point, when I only need it to display two numbers beyond the decimal point. For example,
they are returned as
33.3333333333 or 16.6666666666
(My SQL code is listed in the snippet box below)
-------------------------- ---------
Instead, I need to be able to do two things. (1) display two decimal numbers past the decimal,
33.33 or 16.66 without rounding. And secondly to be able to round the number beyond the decimal up to the next highest value, or to round it down to the next lowest number. Like
33.00 and 17.00
they are returned as
33.3333333333 or 16.6666666666
(My SQL code is listed in the snippet box below)
--------------------------
Instead, I need to be able to do two things. (1) display two decimal numbers past the decimal,
33.33 or 16.66 without rounding. And secondly to be able to round the number beyond the decimal up to the next highest value, or to round it down to the next lowest number. Like
33.00 and 17.00
DECLARE @EmployeeCount int
DECLARE @inputID int
SET @inputID=2
SELECT @EmployeeCount=COUNT(DISTINCT(intUserID)) from tableSendResponse as theTotal
where SendID IS NOT NULL AND (SendID=@inputID)
PRINT @EmployeeCount
SELECT
convert(varchar(30), DATEADD(hh,DATEPART(hh, [ResponseDateTime])), 100) dates,
((CAST(COUNT(intUserID) AS FLOAT)/@EmployeeCount)*100) theCount
FROM
tableSendResponse where ResponseDateTime IS NOT NULL
GROUP BY
convert(varchar(30), DATEADD(hh, DATEPART(hh, [ResponseDateTime]),
CAST(FLOOR(CAST([ResponseDateTime] AS FLOAT)) AS DATETIME)),100)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.