I think this is the best solution in the real world, although I agree
with DRH that different division operators are a bad thing.

Surely if somebody wants the result as an integer, they can use
sqlite3_column_int() to pull the result out?  Or even write a function
to do whatever rounding they see fit.

Oracle, however, returns the following:


   CREATE TABLE test_table1(a INTEGER, b NUMBER(21,18));
   
   INSERT INTO test_table1 VALUES(5,5);
   
   SELECT a/2, b/2 FROM test_table1;



2.5 | 2.5

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 02 November 2005 15:37
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Proposed 3.3.0 changes. Was: 5/2==2

Consider the following SQL:

   CREATE TABLE t1(a INTEGER, b REAL);
   INSERT INTO t1 VALUES(5,5);
   SELECT a/2, b/2 FROM t1;

>From the above SQL, SQLite version 3.2.7 and earlier will return

   2|2

If my proposed changes for 3.3.0 go in, then the result will be:

   2.5|2.5

If I understand what most people are saying, the SQL standard says that
the result should be:

   2|2.5

Does this correctly summarize the situation?

Do other SQL database engines consistently return the 3rd case?

Am I alone in thinking that a division operator that does different
things depending on the declared datatype of a column is an abomination?

Does anybody have a real-world example where any of this will actually
make a difference, or is this really just an academic argument?

--
D. Richard Hipp <[EMAIL PROTECTED]>



Reply via email to