Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display two digits after decimal point in SQL Server

I have table which has a column of float data type in SQL Server I want to return my float datatype column value with 2 decimal places.

for ex: if i insert 12.3,it should return 12.30

if i insert 12,it should return 12.00

like image 642
Santosh Avatar asked Nov 21 '13 11:11

Santosh


People also ask

How get after decimal value in SQL Server?

For bigint use SELECT substr((2.938 % 1)::text,3)::bigint; , else use text result.

How do I cut to 2 decimal places in SQL?

A) Using TRUNCATE function with a positive number of decimal places. In this example, the TRUNCATE() function truncated a number down to two decimal places.


1 Answers

select cast(your_float_column as decimal(10,2)) from your_table 

decimal(10,2) means you can have a decimal number with a maximal total precision of 10 digits. 2 of them after the decimal point and 8 before.
The biggest possible number would be 99999999.99

like image 161
juergen d Avatar answered Sep 22 '22 18:09

juergen d