Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 399
Muhammad Ali Avatar asked Oct 19 '25 11:10

Muhammad Ali


1 Answers

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

select cast(101.32650000 as decimal(10,4));
  • SQL Fiddle Demo
like image 137
sgeddes Avatar answered Oct 21 '25 02:10

sgeddes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!