May 27, 2015 at 12:05 am
Comments posted to this topic are about the item Arithmetic Operation Results
May 27, 2015 at 2:00 am
[font="Courier New"]select 100 / (100 / 108)[/font]
is a similar example that yields "Divide by zero error encountered" - a strange backdoor to getting this error.txtPost_CommentEmoticon(';-)');
May 27, 2015 at 2:02 am
Easy one. Been bitten by integer division many, many times.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 27, 2015 at 5:34 am
Koen Verbeeck (5/27/2015)
Easy one. Been bitten by integer division many, many times.
Agreed on both points. Integer division can also be used to your advantage, but that article isn't published yet.
May 27, 2015 at 5:56 am
This was removed by the editor as SPAM
May 27, 2015 at 6:53 am
Ed Wagner (5/27/2015)
Koen Verbeeck (5/27/2015)
Easy one. Been bitten by integer division many, many times.Agreed on both points. Integer division can also be used to your advantage, but that article isn't published yet.
It's quite useful when you don't need the remainder of the division, indeed.
In all other cases, it's just extremely frustrating 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 27, 2015 at 7:56 am
Really easy - I am (almost) ashamed that I got a full point...
Thanks, Remberto!
May 27, 2015 at 7:59 am
Fairly simple. Scored 1 mark.
Thanks.
May 27, 2015 at 8:08 am
Yep, an easy one. I've dealt with this before.
May 27, 2015 at 8:53 am
Koen Verbeeck (5/27/2015)
It's quite useful when you don't need the remainder of the division, indeed.
In all other cases, it's just extremely frustrating 😀
+1
When it's needed, it should be accompanied by a comment.
I'm learning Python which has "floor" division of integers. That takes some getting used to. It differs from integer division on the treatment of negative numbers.
May 27, 2015 at 10:04 am
It's nice to have a question I can do in my head once in a while.
Don Simpson
May 27, 2015 at 2:42 pm
Um, you didn't say in SQL!! Good question, I knew the answer but just like doing the math in my head. 😀
May 27, 2015 at 2:59 pm
If the question has a 'select' statement is SQL. Cheers:-)
May 27, 2015 at 10:26 pm
Simple One 🙂
May 28, 2015 at 9:27 am
Say WHAT?!?
Apparently I have NOT been around the block enough times, because this was new to me.
I would have not suspected that 1/2 is NOT .5....!
No small wonder that folks get bitten on this. It is just not what you expect.
If I'm dealing with a variable that I've declared, then I think I might have a chance of being more aware of how the datatype would affect the math...
I just had to do some testing.
SQL2008R2:
select CAST(100 AS Decimal)/CAST(200 AS Decimal) --> 0.5000000000000000000
select CAST(100 AS Decimal)/200 --> .5000000
select 100/CAST(200 AS Decimal) --> 0.5000000000000000000
select CAST(100 AS float)/CAST(200 AS Decimal) --> 0.5 interesting...
select 100.0/200 --> .5000000
select 100/200 --> 0
select 108/100 --> 1
hmmmm....
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply