Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Dennis Volodomanov
Thank you Simon and Igor for suggesting the cast() - that works without me having to change anything! And of course I appreciate everyone's replies as well. Dennis ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Igor Tandetnik
"Dennis Volodomanov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Funny enough, but it doesn't work on real data using v3.6.1... > > Here's the table: > > sqlite> .dump test_table > BEGIN TRANSACTION; > CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID2 INTEGER, >

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Simon Davies
Not sure about replacing the collation sequence - does not sound easier than recreating the table. You could just add a view: sqlite> CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ...> ExternalID2 INTEGER, ...> ExternalID INTEGER, ...>

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Dennis Volodomanov
> Declaring the column as integer does not prevent you from storing strings: > > Yes, except for a small problem of updating all live databases with the new column type. I don't think I can update the column type without recreating the table, right? It's not hard, so if it comes down to

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Simon Davies
Hi Dennis, Declaring the column as integer does not prevent you from storing strings: SQLite version 3.6.0 Enter ".help" for instructions sqlite> BEGIN TRANSACTION; sqlite> CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID2 INTEGER, ...> ExternalID ...> INTEGER, Value INTEGER);

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Dennis Volodomanov
> Works just fine with 3.6.1 if you declare the Value column to be > INTEGER. As it is, I have no idea what collation is used, but the > Value column will be declared to default to TEXT values, as shown by > > select typeof(value) from test_table; > I haven't tried that, but I cannot declare it

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Mihai Limbasan
Dennis Volodomanov wrote: Funny enough, but it doesn't work on real data using v3.6.1... Here's the table: sqlite> .dump test_table BEGIN TRANSACTION; CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID2 INTEGER, ExternalID INTEGER, Value ); INSERT INTO "test_table"

Re: [sqlite] SQL statement to get min/max values

2008-08-15 Thread Dennis Volodomanov
Funny enough, but it doesn't work on real data using v3.6.1... Here's the table: sqlite> .dump test_table BEGIN TRANSACTION; CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID2 INTEGER, ExternalID INTEGER, Value ); INSERT INTO "test_table" VALUES(1007,1,37,'-5'); INSERT INTO

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Greg Morphis
I've got 3.6.0 and it works fine here On Thu, Aug 14, 2008 at 9:09 PM, Dennis Volodomanov <[EMAIL PROTECTED]> wrote: >> I'm using 3.3.5, I'll get the latest and see if works there or not in > a >> few minutes. > > Ok, it works in 3.6.1 - sorry for the troubles... I'll just upgrade the > program

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Dennis Volodomanov
> Could it be that since you're not defining a type for Data it assumes > string? > Try creating the table with > id integer, externalid integer, data number (or numeric) That Data column could contain anything (int, double, string), it'll be up to the application's logic to only get Data for

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Greg Morphis
Could it be that since you're not defining a type for Data it assumes string? Try creating the table with id integer, externalid integer, data number (or numeric) On Thu, Aug 14, 2008 at 7:00 PM, Dennis Volodomanov <[EMAIL PROTECTED]> wrote: > Hello all, > > I've tried a few SQL statements, but

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Dennis Volodomanov
> What version of SQLite are you using? I'm using the 3.5.7 version that > came > with OS X 10.5, and I get -2 as expected. I'm using 3.3.5, I'll get the latest and see if works there or not in a few minutes. > Also, what's with the superfluous subquery? Why not just say > > SELECT max(Data)

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Stephen Oberholtzer
On Thu, Aug 14, 2008 at 9:45 PM, Dennis Volodomanov < [EMAIL PROTECTED]> wrote: > > Seems to work ok for me. What values were you expecting? > > Yes, that works. Bad example on my part, sorry. > > What doesn't work is this: > > 1|2|-7 > 2|2|-5 > 3|2|-20 > 4|2|-5 > 5|2|-2 > > SELECT max(Data) FROM

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Dennis Volodomanov
> Seems to work ok for me. What values were you expecting? Yes, that works. Bad example on my part, sorry. What doesn't work is this: 1|2|-7 2|2|-5 3|2|-20 4|2|-5 5|2|-2 SELECT max(Data) FROM (SELECT Data FROM test_table WHERE ExternalID=2); This returns a -5, while I'm expecting a -2. Thank

Re: [sqlite] SQL statement to get min/max values

2008-08-14 Thread Nuno Lucas
On Fri, Aug 15, 2008 at 1:00 AM, Dennis Volodomanov <[EMAIL PROTECTED]> wrote: > Suppose I have a table like this: > > CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID, Data); > > And some contents: > > 1| 2| -7 > 2| 2| 5 > 3| 1| 0 > 4| 2| -20 > 5| 2| -5 > 6| 2| 1 > 7| 1| 10 > > Now,

[sqlite] SQL statement to get min/max values

2008-08-14 Thread Dennis Volodomanov
Hello all, I've tried a few SQL statements, but can't seem to get it to work properly, so I'd like to ask your help. Suppose I have a table like this: CREATE TABLE test_table (ID INTEGER PRIMARY KEY, ExternalID, Data); And some contents: 1| 2| -7 2| 2| 5 3| 1| 0 4| 2| -20 5| 2| -5 6| 2| 1 7|