Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Here I want to select only first 4 integer.

50.9211428571429
161.142857142857

like this i want to fetch..plz tell me fast..
50.92
161.14
Posted
Comments
Suvendu Shekhar Giri 2-Mar-15 4:17am    
Not sure what you want. The result you want seems to rounded up to 2 digits after decimal. But you have mentioned to select 4 integer. Can you clarify a little more?
Member 11337367 2-Mar-15 4:26am    
I want to take out only 2 digit after point(.)..

Use like this

Select CAST('161.142857142857' as Numeric(20,2))


OR

Select CONVERT(Numeric(20,2),'161.142857142857')
 
Share this answer
 
If you are using sql server 2012, then use SQL Server's FORMAT() function[^], e.g.:
SQL
SELECT FORMAT(50.9211428571429, 'F2');
SELECT FORMAT(161.142857142857, 'F2')
 
Share this answer
 
This will help you-
SQL
FORMAT(50.9211428571429,'N2')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900