Many times when you have decimal values in your calculation of sql you didn't get exact result or some values get round off so it depend upon the function or Datatype in which you are converting your calculated values.
Below are some output and behaviour of a decimal number used converted with Different Datatypes and functions.
--Testing Number
select 00.8788
Datatype int
select cast(00.8788 as int)---0
Datatype float
select 00.8788 as float--0.8788
converting to decimal
select convert(decimal(10,2),00.8788)--0.88
converting to numeric
select convert(numeric(10,2),00.8788)--0.88
Round function with cast
select ROUND(cast ('00.8788' as float),2)--0.88
Round Function
select ROUND('00.8788',2)--0.88
Cieling Function
SELECT Ceiling(00.8788)--1
Floor Function
select FLOOR(00.8788)--0
No comments:
Post a Comment