Muhammad Ali
Muhammad Ali

Reputation: 138

How to get 4 digit numbers after decimal including before decimal also in SQL

I have a data that is101.32650000 and I want to get 101.3265 only ... I tried using right function, but the disadvantage is that digits before decimal can vary.

Upvotes: 4

Views: 5214

Answers (3)

Muhammad Ali
Muhammad Ali

Reputation: 138

cast(col_name as decimal(28,4)) as col_name

Upvotes: 0

sgeddes
sgeddes

Reputation: 62841

How about using cast with decimal and scale of 4. Something like:

select cast(101.32650000 as decimal(10,4));

Upvotes: 8

Rhamdeck Lansing
Rhamdeck Lansing

Reputation: 44

SELECT CAST(101.32650000 AS DECIMAL(10,4));

Upvotes: 0

Related Questions