How to remove the trailing 0000
with a sql expression? for example, 1.0100000
-
what I need is 1.01
after running it, thanks in advance!
Asked
Active
Viewed 156 times
-1
-
2what is the datatype ? – ogres Nov 04 '15 at 08:46
-
1Which DBMS are you using? Postgres? Oracle? – Nov 04 '15 at 08:49
-
datatype is decimal 35, using mysql – markit Nov 04 '15 at 08:51
-
*Why* do you want to do that? A database may be the wrong place to worry about presentation. – Hans Kesting Nov 04 '15 at 08:56
-
2`CAST(
AS DECIMAL(3,2))` – Abhishek Nov 04 '15 at 09:01
1 Answers
1
If you don't want your numbers to be rounded (just ignore the last decimals), use the TRUNCATE
function:
TRUNCATE(1.23456, 4) --yields 1.2345
If you want your number to be rounded, use the ROUND
function:
ROUND(1.23456, 4) --yields 1.2346

Tobb
- 11,850
- 6
- 52
- 77