August 17, 2016 at 12:02 pm
No I am not missing values I am getting the exact results what I am expecting, I tested.
August 17, 2016 at 12:23 pm
I did test as well.
CREATE TABLE #Test(
Units decimal(10,5),
DesiredResult decimal(10,5),
);
INSERT INTO #Test SELECT
0.3, 0.3 UNION ALL SELECT
0.1, 0.1 UNION ALL SELECT
1.4, 1.4 UNION ALL SELECT
1.5, 2 UNION ALL SELECT
1.7, 2 UNION ALL SELECT
0.8, 1 UNION ALL SELECT
0.49, 0.49;
SELECT *,
CASE WHEN ROUND(Units,0) = ROUND(Units,0,1)
THEN Units ELSE ROUND(Units,0)
END,
case when (units - floor(units)) < 0.49 then round(units,2)
when (units - floor(units)) > = 0.50 then round(units,0)
end
FROM #Test
GO
DROP TABLE #Test
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply