You are wrong about float.
The following code snippet
create table test (a1 float, a2 decimal(15,2), a3 numeric(15,2), a4 real)
insert into test values (2.7777,2.7777,2.7777,2.7777)
select * from test
produces the results
2.7777 2.78 2.78 2.7777
But if I change the definition of a2 and a3
create table test2 (a1 float, a2 decimal(15,4), a3 numeric(15,4), a4 real)
insert into test2 values (2.7777,2.7777,2.7777,2.7777)
select * from test2
gives
2.7777 2.7777 2.7777 2.7777
To get your desired result of 2.77 then you can use
ROUND [
^] forcing it to truncate. Compare these results from
select round(a1, 2), round(a1, 2, 1), round(a2, 2), round(a2, 2, 1), round(a3, 2), round(a3, 2, 1), round(a4, 2), round(a4, 2, 1) from test2
which gives the results (I've added vertical bars to make it easier to see each column
2.78 2.77 | 2.7800 2.7700 | 2.7800 2.7700 | 2.78 2.77
You should really be doing the truncation in your presentation layer though.
In summary then, store your data in a column of type
float
,
decimal
(with enough digits right of the decimal point defined),
numeric
(comment as for decimal) or
real
and either truncate it in the UI or use
ROUND(yourColumnName, 2, 1)