On 15 Sep 2014, at 8:33pm, Dave Wellman <dwell...@ward-analytics.com> wrote:

> Simon,
> I'm really surprised at that. Effectively what this means is that the answer
> that Sqlite returns may or may not be the correct result.

What ?  No.  It's correct.  The answer is not known, and NULL means "I don't 
know".  Given that anything divided by 0 is infinity, and anything divided by 
itself is 1 what is 0/0 ?

> I realise this may
> only be in a single circumstance but that is still what it means.  I suppose
> we then get into a discussion of what is the 'correct result'. I completely
> understand that NULL is unknown, but I've always thought that there is a
> difference between unknown and 'error'.

It is not an error to divide things by zero as long as that's what you meant to 
do.  An error would be to divide by 6 when you meant to divide by zero.

You may be used to thinking the answer is "error" because you see calculators 
and spreadsheets showing "error" on their display.  But that's just your 
calculator refusing to get into a philosophical discussion about the nature of 
transfinite numbers.  Because it hasn't had enough beer yet.

> I was always taught in maths that dividing by 0 is not possible (certainly
> at school, I don't know what happens if you study maths at degree level),
> the closest that I ever got to an answer for that calculation was
> 'infinity'.

That's because you stopped at school.  Ask a mathematician.  They didn't stop 
at school but they still don't have a good answer.  It's a way of avoiding the 
problem.  It's as correct to say "Not A Number" or "I don't know".  And since 
SQL conveniently has the NULL value for "unknown" that's what we use.  You 
might find it interesting to read the beginning of this:

<http://en.wikipedia.org/wiki/NaN>

By the way, if you run

SELECT max(x) FROM myTable

and myTable has no rows, what answer would you expect ?  I don't mean "What 
would you expect having read the documentation ?" I'm interested in what your 
first thought was.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to