[sqlite] Creating Histogram fast and efficiently :)

2008-12-31 Thread Jonathon
Hello all, I have a column of numbers in a table, and I was wondering if it is possible to create a histogram out of it fast and efficiently? For example, assuming the data in the column is: 1, 5, 10, 12, 12, 15, 20, 20, 20.. I would like to return: 'less than 10' --> 2 'less than 20 and

Re: [sqlite] Creating Histogram fast and efficiently :)

2008-12-31 Thread Russell Leighton
create table numbers (val integer); insert into numbers values (1); insert into numbers values (5); sqlite> select * from numbers order by val; 1 5 10 12 12 15 20 20 20 select case when val < 10 then 1 when val >=10 and val < 20 then 2 else 3 end as bin, count(1) as c

Re: [sqlite] SQLITE_MAX_VARIABLE_NUMBER and .import for very wide file

2008-12-31 Thread Webb Sprague
See below. On Sun, Dec 28, 2008 at 11:56 PM, Chris Wedgwood wrote: > On Sun, Dec 28, 2008 at 11:49:34PM -0800, Webb Sprague wrote: > >> I am sure there is a better way to deal with 12K rows by 2500 columns, >> but I can't figure it out > > 2500 columns sounds like a nightmare

[sqlite] Transaction?

2008-12-31 Thread John Hawley
OK here's the problem:- I decided I needed a little app to manage some data in 3rd party binary files, specifically, I needed to store the user generated data from the files in a database so that I could retrieve the data in a massaged form. As others have also decided that they need to do

Re: [sqlite] Transaction?

2008-12-31 Thread Derrell Lipman
On Wed, Dec 31, 2008 at 11:36 AM, John Hawley wrote: > the following block of code executes 2 or 3 orders of magnitude slower > than 1 think it should ( the db was opened in earlier code) > Yup, you're committing each insert to disk (a VERY slow process) rather than

Re: [sqlite] SQLITE_MAX_VARIABLE_NUMBER and .import for very widefile

2008-12-31 Thread Griggs, Donald
Regarding: >> I am sure there is a better way to deal with 12K rows by 2500 >> columns, but I can't figure it out I wonder if you might want to use *sed* or *awk* or *perl* to preprocess the data before import. A "master" table could contain the unique person id, plus the fields that you

[sqlite] Recording history of changes to schema

2008-12-31 Thread BareFeet
Hi all, I want to set up a history of changes in a database schema. I hoped I could simply set up triggers for changes to the SQLite_Master table, like this: create table "BF SQLite_Master History" -- record changes to SQLite_Master ( ID integer primary key , Date date

Re: [sqlite] Creating Histogram fast and efficiently :)

2008-12-31 Thread Jonathon
Thanks Russell :) It works great. J On Wed, Dec 31, 2008 at 5:52 AM, Russell Leighton wrote: > > create table numbers (val integer); > > insert into numbers values (1); > insert into numbers values (5); > > > sqlite> select * from numbers order by val; > 1 > 5