May 10, 2013 at 12:52 am
Ok, I know this is a silly question, but when I execute this code, it returns 1.00; however 3/2 really should be 1.50. What am I doing wrong here?
select cast (3/2 as decimal (5,2)) as 'test'
May 10, 2013 at 1:34 am
You're dividing an integer by an integer, which will return an integer (no decimal places), then the conversion to decimal takes place. Try:-
select cast (3/2.0 as decimal (5,2)) as 'test'
and you get 1.5
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
May 10, 2013 at 9:30 am
oh I see, that makes sense.
Thank you so much, I learned something new today!!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply