Have you heard of rounding errors?  If you want exact numbers you need to 
convert to integers:



sqlite> create table test_col (id integer,base real,thick real);
sqlite> insert into test_col values(89,281.04,0.03);
sqlite> insert into test_col values(90,282.09|1.05);
Error: table test_col has 3 columns but 2 values were supplied
sqlite> insert into test_col values(90,282.09,1.05);
sqlite> insert into test_col values(91,283.11,1.02);
sqlite> insert into test_col values(92,290.08,6.97);
sqlite> SELECT id,base,thick FROM test_col WHERE base > 281.01 AND base - thick 
< 283.11;
89|281.04|0.03
90|282.09|1.05
91|283.11|1.02
92|290.08|6.97
sqlite>
sqlite> create table test_col2 (id integer,base integer,thick integer);
sqlite> insert into test_col values(89,28104,3);
sqlite> insert into test_col values(90,28209,105);
sqlite> insert into test_col values(91,28311,102);
sqlite> insert into test_col values(92,29008,697);
sqlite> SELECT id,base/100,thick/100 FROM test_col WHERE base > 28101 AND base 
- thick < 28311;
89|281.04|0.03
90|282.09|1.05
91|283.11|1.02
s



Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: [email protected] [[email protected]] on 
behalf of Ryan Belcher [[email protected]]
Sent: Tuesday, November 01, 2011 9:37 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Occasional problems with < and >

I should have added that I have database with lots of values like this and I 
run many queries like this.  Sometimes sqlite returns the correct results and 
sometimes it includes results where the values are equal to the base or base - 
thick.  It probably returns the correct result a little over the half the time.

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to