Reputation: 6363
Given these 2 examples, what is the correct syntax to round each example to the whole number. This must be a set operation as the decimal is from a column.
96.001 will be 96
80.01 will be 81
Thank you, Stephen
Upvotes: 1
Views: 2713
Reputation: 13157
declare @myVar1 decimal(6,2)
declare @myVar2 decimal(6,2)
set @myvar1 = 96.001
set @myvar2 = 80.01
SELECT @myvar1, CAST(CEILING(@myVar1) as int), @myvar2, CEILING(@myVar2)
Result:
96.001 | 96 | 80.010 | 81
Upvotes: 0
Reputation: 453287
;WITH T(C) AS
(
SELECT 96.001
UNION ALL
SELECT 80.01
)
SELECT CEILING(CAST(C AS DECIMAL(18,2)))
FROM T
Upvotes: 4