How to exact decimal place show in sql

Posted by Jayakumars under ASP.NET on 8/13/2011 | Points: 10 | Views : 2873 | Status : [Member] [MVP] | Replies : 2
hi

How to Exact Fraction value show in Sql Server


For Ex:My Query like this
select (14/8)as Test
Ans:1

but i have run calculator same calculation 14/8 my answer is 1.75

i have convert my query decimal datatype but sql server did not show
correct value
SELECT CONVERT(DECIMAL(10,2),(14/8)) amt

i need 1.75 my output how to achieve this sql query

Mark as Answer if its helpful to you


Responses

Posted by: Nisar87 on: 8/13/2011 [Member] Starter | Points: 25

Up
0
Down
Modify your query as below
select (14.0/8.0) as Test


_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 8/15/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Jayakumar,

If you using decimal value means you get exact value....

Ex:
 Select (14.00/8.00)


In case you using integer value means just convert into decimal then using that values.
Ex:
select (convert(decimal(18,2),14)) / (convert(decimal(18,2),8))


Thanks,
T.Saravanan

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response