[sqlite] Enhancement Request: sqlite3 shell output mode "insert" include column names

2015-04-07 Thread Roy Keene
All, The current SQLite3 shell has a ".mode" directive to set the output mode. One such mode is called "insert" which is intended to generate INSERT statements. The "insert" output mode is very basic, however, and lacks column names in the output. Attached is a patch to include the colu

[sqlite] Transpose selected rows into columns

2015-04-07 Thread Drago, William @ CSG - NARDA-MITEQ
Igor, Your solution works well. What I can't figure out is how to efficiently create a column representing V5-V0. SerialNumber | V0 | V5 | Vdiff -|---|--|--- 123 | 0.2 | 0.6 | 0.4 This is what I'm using, but it takes twice as long: select SerialNumber

[sqlite] Transpose selected rows into columns

2015-04-07 Thread Drago, William @ CSG - NARDA-MITEQ
Simon, Your solution almost works. It returns a lot of duplicate rows and I don't know how to fix that. I'm using what Igor posted. Thanks, -- Bill Drago Senior Engineer L3 Narda-MITEQ 435 Moreland Road Hauppauge, NY 11788 631-272-5947 / William.Drago at L-3COM.com > -Original Message

[sqlite] Transpose selected rows into columns

2015-04-07 Thread Jim Morris
You might try select SerialNumber, V0, V5, V5-V0 from (select SerialNumber, max(case Stim when 'V0' then Resp else null end) V0, max(case Stim when 'V5' then Resp else null end) V5 from MyTable group by SerialNumber) On 4/7/2015 6:58 AM, Drago, William @ CSG - NARDA-MITEQ wrote: > Igor,

[sqlite] Transpose selected rows into columns

2015-04-07 Thread John McKown
On Fri, Mar 27, 2015 at 10:48 AM, Drago, William @ CSG - NARDA-MITEQ < William.Drago at l-3com.com> wrote: > All, > > Say I have a table that looks like this: > > > SerialNumber | Stim | Resp > -|---|- > .| .| . > .| .| . > 123

[sqlite] Transpose selected rows into columns

2015-04-07 Thread John McKown
OOPS, a slight mistake (incomplete) SELECT * FROM CROSSTAB('SELECT SerialNumber, Stim, Resp FROM table WHERE Stim in (''V0'',''V5'') ORDER BY 1, 2) AS ct(SerialNumber, V0, V5) On Tue, Apr 7, 2015 at 9:14 AM, John McKown wrote: > On Fri, Mar 27, 2015 at 10:48 AM, Drago, William @ CSG - NARDA-MIT

[sqlite] Transpose selected rows into columns

2015-04-07 Thread Jim Callahan
?Why not CREATE an intermediate SQL VIEW or TABLE with V0 and V5 and then use the resulting VIEW or TABLE as input to a second query that computes the diff? Or use R? First query: CREATE TABLE newtable AS SELECT ? max(case Stim when 'V0' then Resp else null end) V0, max(case

[sqlite] Transpose selected rows into columns

2015-04-07 Thread John McKown
I'm an idiot, thanks for not pointing that out. I thought I was on the PostgreSQL forum and managed to mess up. My apologies to all. On Tue, Apr 7, 2015 at 9:19 AM, John McKown wrote: > OOPS, a slight mistake (incomplete) > > SELECT * FROM CROSSTAB('SELECT SerialNumber, Stim, Resp FROM table WHE

[sqlite] Transpose selected rows into columns

2015-04-07 Thread Petite Abeille
> On Apr 7, 2015, at 5:53 PM, John McKown > wrote: > > I'm an idiot, thanks for not pointing that out. I thought I was on the > PostgreSQL forum and managed to mess up. My apologies to all. We all have been there. I, for one, wish SQLite had some syntax sugar such as PIVOT/UNPIVOT: http://o

[sqlite] Different timings on min() and max()

2015-04-07 Thread Paul Caskey
Hello, Any idea why there is such a performance hit when I ask for both min() and max() at the same time? Shouldn't it be just as fast as querying them individually? Nothing else is reading or writing to this data at this time. [14:32 sql04:/opt/pcaskey]$ cat ~/.sqliterc .output /dev/null PRAGMA

[sqlite] Different timings on min() and max()

2015-04-07 Thread Simon Slavin
On 7 Apr 2015, at 9:42pm, Paul Caskey wrote: > Any idea why there is such a performance hit when I ask for both min() and > max() at the same time? Shouldn't it be just as fast as querying them > individually? Did you try using EXPLAIN QUERY PLAN ? If the column you're minning (or maxing) is i

[sqlite] Different timings on min() and max()

2015-04-07 Thread Scott Hess
On Tue, Apr 7, 2015 at 1:42 PM, Paul Caskey wrote: > Any idea why there is such a performance hit when I ask for both min() and > max() at the same time? Shouldn't it be just as fast as querying them > individually? This has come up before. Either alone can be satisfied from an index lookup, whi

[sqlite] Enhancement Request: sqlite3 shell output mode "insert" include column names

2015-04-07 Thread Joe Mistachkin
Roy Keene wrote: > > The "insert" output mode is very basic, however, and lacks column > names in the output. > Can you try the changes on the "expShell" branch and see if they work for your use case? In order to get column names, you'll need to set the headers to "on". -- Joe Mistachkin

[sqlite] fts5

2015-04-07 Thread Scott Hess
On Thu, Sep 11, 2014 at 8:58 AM, Dan Kennedy wrote: > Fts5 is still in the experimental stage at the moment. > > If anybody has any ideas for useful features, or knows of problems with FTS4 > that could be fixed in FTS5, don't keep them to yourself! Apologies for not noticing this thread earlier!

[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
Hi I am trying to use SQLite c api to create a db, table and then do a select query but i am getting following error #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ Here is the code call #define SELECT_DN "select kindex from TBL where dn=?" char buffer[100] = "a/b/c/d

[sqlite] error during sqlite_bind

2015-04-07 Thread Igor Tandetnik
On 4/7/2015 8:04 PM, Kumar Suraj wrote: > if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, strlen(command), > &newStmt, NULL) ) != SQLITE_OK ) command: undeclared identifier. -- Igor Tandetnik

[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
I have not added the whole code.. command is defined.. in my code.. On Tue, Apr 7, 2015 at 5:42 PM, Igor Tandetnik wrote: > On 4/7/2015 8:04 PM, Kumar Suraj wrote: > >> if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, strlen(command), >> &newStmt, NULL)

[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
You can add this to top of the code.. char command[512]; snprintf(command, 512, SELECT_DN); On Tue, Apr 7, 2015 at 6:11 PM, Kumar Suraj wrote: > I have not added the whole code.. command is defined.. in my code.. > > On Tue, Apr 7, 2015 at 5:42 PM, Igor Tandetnik wrote: > >> On 4/7/201

[sqlite] error during sqlite_bind

2015-04-07 Thread Igor Tandetnik
On 4/7/2015 9:11 PM, Kumar Suraj wrote: > You can add this to top of the code.. > > char command[512]; > snprintf(command, 512, SELECT_DN); I don't see anything wrong in the code you've shown. The problem must lie in the code you haven't. My guess would be, the query you are preparing i

[sqlite] error during sqlite_bind

2015-04-07 Thread Richard Hipp
On 4/7/15, Igor Tandetnik wrote: > On 4/7/2015 9:11 PM, Kumar Suraj wrote: >> You can add this to top of the code.. >> >> char command[512]; >> snprintf(command, 512, SELECT_DN); > > I don't see anything wrong in the code you've shown. The problem must > lie in the code you haven't. My gu

[sqlite] Enhancement Request: sqlite3 shell output mode "insert" include column names

2015-04-07 Thread Roy Keene
Joe, Seems to work. My use case is piping sqlite3 to sqlite3 with something other than 'SELECT *'. Thanks ! Roy Keene On 04/07/2015 04:21 PM, Joe Mistachkin wrote: > Roy Keene wrote: >> The "insert" output mode is very basic, however, and lacks column >> names in the output. >> > Can you