SQLite Forum

Incorrect Result From SQLite Query
Login
It shouldn't matter - See example below where I make text columns and sometimes populate text and sometimes numbers, SQLite is ambivalent:

```
  -- SQLite version 3.35.4  [ Release: 2021-04-02 ]  on  SQLitespeed version 2.1.3.11.
================================================================================================

CREATE TABLE report_A (
   rows INTEGER PRIMARY KEY,
   amount TEXT,
   rate TEXT
 );


INSERT INTO report_A VALUES
  ( 1,100 , 0.120 )
 ,( 2, 50 , 0.150 )
 ,( 3,'20', 0.005 )
 ,( 4, 60 ,'0.130')
 ,( 5, 10 ,'0.150')
 ,( 6,'67', 0.005 )
 ,( 7, 50 , 0.001 )
 ,( 8,'87','0.006')
 ,( 9,'12','0.005')
 ,(10, 43 , 0.120 )
 ;


SELECT rows, amount, (amount * rate) AS cost
 FROM report_A

  --     rows    |amount|     cost
  -- ------------|------|---------
  --       1     |  100 |     12.0
  --       2     |  50  |      7.5
  --       3     |  20  |      0.1
  --       4     |  60  |      7.8
  --       5     |  10  |      1.5
  --       6     |  67  |    0.335
  --       7     |  50  |     0.05
  --       8     |  87  |    0.522
  --       9     |  12  |     0.06
  --      10     |  43  |     5.16


```

Still a good idea to run the typeof() query though, just in case we learn something else. My bet is however the program he uses is getting it wrong - I think it's the same program recently mentioned in another thread where it didn't deal correctly with Windows UAC - perhaps it's just a tad old.